History

dsputil: Split off IDCT bits into their own context

Diego Biurrun committed 12 years ago

Commit e3fcb141 parent adcb83978 files · +1235 −896Browse files

Unified · Split

78 files
  1. configure +21 −19
  2. doc/optimization.txt +0 −3
  3. libavcodec/Makefile +3 −2
  4. libavcodec/aic.c +11 −12
  5. libavcodec/arm/Makefile +13 −10
  6. libavcodec/arm/dsputil_arm.h +0 −4
  7. libavcodec/arm/dsputil_armv6.S +0 −27
  8. libavcodec/arm/dsputil_init_arm.c +0 −60
  9. libavcodec/arm/dsputil_init_armv6.c +0 −18
  10. libavcodec/arm/idctdsp_arm.S +1 −1
  11. libavcodec/arm/idctdsp_arm.h +34 −0
  12. libavcodec/arm/idctdsp_armv6.S +48 −0
  13. libavcodec/arm/idctdsp_init_arm.c +98 −0
  14. libavcodec/arm/idctdsp_init_armv5te.c +3 −3
  15. libavcodec/arm/idctdsp_init_armv6.c +48 −0
  16. libavcodec/arm/idctdsp_init_neon.c +4 −4
  17. libavcodec/arm/idctdsp_neon.S +1 −1
  18. libavcodec/asv.c +0 −1
  19. libavcodec/asv.h +2 −0
  20. libavcodec/asvdec.c +9 −7
  21. libavcodec/asvenc.c +1 −0
  22. libavcodec/cavs.c +4 −3
  23. libavcodec/cavs.h +2 −2
  24. libavcodec/cavsdsp.c +1 −1
  25. libavcodec/dnxhddec.c +26 −26
  26. libavcodec/dnxhdenc.c +5 −4
  27. libavcodec/dsputil.c +1 −161
  28. libavcodec/dsputil.h +0 −66
  29. libavcodec/dvdec.c +5 −4
  30. libavcodec/dxva2_mpeg2.c +1 −1
  31. libavcodec/eamad.c +5 −4
  32. libavcodec/eatgq.c +1 −1
  33. libavcodec/eatqi.c +4 −3
  34. libavcodec/g2meet.c +6 −6
  35. libavcodec/h263.c +4 −4
  36. libavcodec/idctdsp.c +197 −0
  37. libavcodec/idctdsp.h +104 −0
  38. libavcodec/intrax8.c +8 −7
  39. libavcodec/ljpegenc.c +5 −4
  40. libavcodec/mdec.c +11 −9
  41. libavcodec/mimic.c +5 −5
  42. libavcodec/mjpegdec.c +6 −4
  43. libavcodec/mjpegdec.h +2 −2
  44. libavcodec/mjpegenc_common.c +1 −1
  45. libavcodec/mjpegenc_common.h +1 −1
  46. libavcodec/mpeg12dec.c +15 −15
  47. libavcodec/mpeg4videodec.c +20 −19
  48. libavcodec/mpeg4videoenc.c +14 −14
  49. libavcodec/mpegvideo.c +27 −25
  50. libavcodec/mpegvideo.h +2 −0
  51. libavcodec/mpegvideo_enc.c +11 −9
  52. libavcodec/mpegvideo_xvmc.c +1 −1
  53. libavcodec/msmpeg4.c +5 −5
  54. libavcodec/nuv.c +1 −0
  55. libavcodec/ppc/Makefile +1 −1
  56. libavcodec/ppc/dsputil_altivec.h +0 −3
  57. libavcodec/ppc/dsputil_ppc.c +0 −6
  58. libavcodec/ppc/idctdsp.c +27 −3
  59. libavcodec/proresdec.c +1 −1
  60. libavcodec/proresdsp.c +1 −1
  61. libavcodec/rtjpeg.c +4 −4
  62. libavcodec/rtjpeg.h +3 −2
  63. libavcodec/vc1dec.c +69 −47
  64. libavcodec/wmv2.c +12 −11
  65. libavcodec/wmv2dsp.c +1 −1
  66. libavcodec/x86/Makefile +6 −4
  67. libavcodec/x86/cavsdsp.c +2 −1
  68. libavcodec/x86/dsputil_init.c +0 −85
  69. libavcodec/x86/dsputil_mmx.c +0 −135
  70. libavcodec/x86/dsputil_x86.h +0 −7
  71. libavcodec/x86/idct_mmx_xvid.c +1 −1
  72. libavcodec/x86/idct_sse2_xvid.c +1 −1
  73. libavcodec/x86/idctdsp.h +31 −0
  74. libavcodec/x86/idctdsp_init.c +106 −0
  75. libavcodec/x86/idctdsp_mmx.c +168 −0
  76. libavcodec/x86/mpegvideoenc_template.c +1 −1
  77. libavcodec/x86/proresdsp_init.c +1 −1
  78. libavcodec/x86/simple_idct.c +1 −1
configure+21−19
@@ -1546,6 +1546,7 @@ CONFIG_EXTRA=" · 1545 unmodified lines
1546 huffman1546 huffman
1547 huffyuvdsp1547 huffyuvdsp
1548 huffyuvencdsp1548 huffyuvencdsp
1549 idctdsp
1549 intrax81550 intrax8
1550 lgplv31551 lgplv3
1551 lpc1552 lpc
@@ -1703,6 +1704,7 @@ threads_if_any="$THREADS_LIST" · 151 unmodified lines
1703 1704
1704# subsystems1705# subsystems
1705dct_select="rdft"1706dct_select="rdft"
1707dsputil_select="idctdsp"
1706error_resilience_select="dsputil"1708error_resilience_select="dsputil"
1707intrax8_select="error_resilience"1709intrax8_select="error_resilience"
1708mdct_select="fft"1710mdct_select="fft"
@@ -1710,7 +1712,7 @@ rdft_select="fft" · 1 unmodified line
1710mpeg_er_select="error_resilience"1712mpeg_er_select="error_resilience"
1711mpegaudio_select="mpegaudiodsp"1713mpegaudio_select="mpegaudiodsp"
1712mpegaudiodsp_select="dct"1714mpegaudiodsp_select="dct"
1713mpegvideo_select="blockdsp dsputil hpeldsp videodsp"1715mpegvideo_select="blockdsp dsputil hpeldsp idctdsp videodsp"
1714mpegvideoenc_select="dsputil mpegvideo qpeldsp"1716mpegvideoenc_select="dsputil mpegvideo qpeldsp"
1715 1717
1716# decoders / encoders1718# decoders / encoders
@@ -1720,16 +1722,16 @@ aac_latm_decoder_select="aac_decoder aac_latm_parser" · 3 unmodified lines
1720ac3_decoder_select="ac3_parser ac3dsp bswapdsp mdct"1722ac3_decoder_select="ac3_parser ac3dsp bswapdsp mdct"
1721ac3_encoder_select="ac3dsp audiodsp dsputil mdct"1723ac3_encoder_select="ac3dsp audiodsp dsputil mdct"
1722ac3_fixed_encoder_select="ac3dsp audiodsp dsputil mdct"1724ac3_fixed_encoder_select="ac3dsp audiodsp dsputil mdct"
1723aic_decoder_select="dsputil golomb"1725aic_decoder_select="golomb idctdsp"
1724alac_encoder_select="lpc"1726alac_encoder_select="lpc"
1725als_decoder_select="bswapdsp"1727als_decoder_select="bswapdsp"
1726amrnb_decoder_select="lsp"1728amrnb_decoder_select="lsp"
1727amrwb_decoder_select="lsp"1729amrwb_decoder_select="lsp"
1728amv_decoder_select="sp5x_decoder"1730amv_decoder_select="sp5x_decoder"
1729ape_decoder_select="bswapdsp"1731ape_decoder_select="bswapdsp"
1730asv1_decoder_select="blockdsp bswapdsp dsputil"1732asv1_decoder_select="blockdsp bswapdsp idctdsp"
1731asv1_encoder_select="bswapdsp dsputil"1733asv1_encoder_select="bswapdsp dsputil"
1732asv2_decoder_select="blockdsp bswapdsp dsputil"1734asv2_decoder_select="blockdsp bswapdsp idctdsp"
1733asv2_encoder_select="bswapdsp dsputil"1735asv2_encoder_select="bswapdsp dsputil"
1734atrac1_decoder_select="mdct sinewin"1736atrac1_decoder_select="mdct sinewin"
1735atrac3_decoder_select="mdct"1737atrac3_decoder_select="mdct"
@@ -1737,23 +1739,23 @@ atrac3p_decoder_select="mdct sinewin" · 1 unmodified line
1737bink_decoder_select="blockdsp hpeldsp"1739bink_decoder_select="blockdsp hpeldsp"
1738binkaudio_dct_decoder_select="mdct rdft dct sinewin"1740binkaudio_dct_decoder_select="mdct rdft dct sinewin"
1739binkaudio_rdft_decoder_select="mdct rdft sinewin"1741binkaudio_rdft_decoder_select="mdct rdft sinewin"
1740cavs_decoder_select="blockdsp dsputil golomb h264chroma qpeldsp videodsp"1742cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
1741cllc_decoder_select="bswapdsp"1743cllc_decoder_select="bswapdsp"
1742comfortnoise_encoder_select="lpc"1744comfortnoise_encoder_select="lpc"
1743cook_decoder_select="audiodsp mdct sinewin"1745cook_decoder_select="audiodsp mdct sinewin"
1744cscd_decoder_select="lzo"1746cscd_decoder_select="lzo"
1745cscd_decoder_suggest="zlib"1747cscd_decoder_suggest="zlib"
1746dca_decoder_select="mdct"1748dca_decoder_select="mdct"
1747dnxhd_decoder_select="blockdsp dsputil"1749dnxhd_decoder_select="blockdsp idctdsp"
1748dnxhd_encoder_select="aandcttables blockdsp dsputil mpegvideoenc"1750dnxhd_encoder_select="aandcttables blockdsp dsputil idctdsp mpegvideoenc"
1749dvvideo_decoder_select="dsputil"1751dvvideo_decoder_select="idctdsp"
1750dvvideo_encoder_select="dsputil"1752dvvideo_encoder_select="dsputil"
1751dxa_decoder_deps="zlib"1753dxa_decoder_deps="zlib"
1752eac3_decoder_select="ac3_decoder"1754eac3_decoder_select="ac3_decoder"
1753eac3_encoder_select="ac3_encoder"1755eac3_encoder_select="ac3_encoder"
1754eamad_decoder_select="aandcttables blockdsp bswapdsp dsputil mpegvideo"1756eamad_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpegvideo"
1755eatgq_decoder_select="aandcttables dsputil"1757eatgq_decoder_select="aandcttables idctdsp"
1756eatqi_decoder_select="aandcttables blockdsp bswapdsp dsputil mpeg1video_decoder"1758eatqi_decoder_select="aandcttables blockdsp bswapdsp idctdsp mpeg1video_decoder"
1757exr_decoder_deps="zlib"1759exr_decoder_deps="zlib"
1758ffv1_decoder_select="golomb rangecoder"1760ffv1_decoder_select="golomb rangecoder"
1759ffv1_encoder_select="rangecoder"1761ffv1_encoder_select="rangecoder"
@@ -1770,7 +1772,7 @@ flv_encoder_select="h263_encoder" · 10 unmodified lines
1770fourxm_decoder_select="blockdsp bswapdsp"1772fourxm_decoder_select="blockdsp bswapdsp"
1771fraps_decoder_select="bswapdsp huffman"1773fraps_decoder_select="bswapdsp huffman"
1772g2m_decoder_deps="zlib"1774g2m_decoder_deps="zlib"
1773g2m_decoder_select="blockdsp dsputil"1775g2m_decoder_select="blockdsp idctdsp"
1774h261_decoder_select="mpeg_er mpegvideo"1776h261_decoder_select="mpeg_er mpegvideo"
1775h261_encoder_select="aandcttables mpegvideoenc"1777h261_encoder_select="aandcttables mpegvideoenc"
1776h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp"1778h263_decoder_select="error_resilience h263_parser h263dsp mpeg_er mpegvideo qpeldsp"
@@ -1790,12 +1792,12 @@ jpegls_decoder_select="golomb mjpeg_decoder" · 13 unmodified lines
1790jpegls_encoder_select="golomb"1792jpegls_encoder_select="golomb"
1791jv_decoder_select="blockdsp"1793jv_decoder_select="blockdsp"
1792lagarith_decoder_select="huffyuvdsp"1794lagarith_decoder_select="huffyuvdsp"
1793ljpeg_encoder_select="aandcttables dsputil"1795ljpeg_encoder_select="aandcttables idctdsp"
1794loco_decoder_select="golomb"1796loco_decoder_select="golomb"
1795mdec_decoder_select="blockdsp dsputil mpegvideo"1797mdec_decoder_select="blockdsp idctdsp mpegvideo"
1796metasound_decoder_select="lsp mdct sinewin"1798metasound_decoder_select="lsp mdct sinewin"
1797mimic_decoder_select="blockdsp bswapdsp dsputil hpeldsp"1799mimic_decoder_select="blockdsp bswapdsp hpeldsp idctdsp"
1798mjpeg_decoder_select="blockdsp dsputil hpeldsp"1800mjpeg_decoder_select="blockdsp hpeldsp idctdsp"
1799mjpeg_encoder_select="aandcttables mpegvideoenc"1801mjpeg_encoder_select="aandcttables mpegvideoenc"
1800mjpegb_decoder_select="mjpeg_decoder"1802mjpegb_decoder_select="mjpeg_decoder"
1801mlp_decoder_select="mlp_parser"1803mlp_decoder_select="mlp_parser"
@@ -1829,13 +1831,13 @@ mss2_decoder_select="error_resilience mpeg_er qpeldsp vc1_decoder" · 27 unmodified lines
1829mxpeg_decoder_select="mjpeg_decoder"1831mxpeg_decoder_select="mjpeg_decoder"
1830nellymoser_decoder_select="mdct sinewin"1832nellymoser_decoder_select="mdct sinewin"
1831nellymoser_encoder_select="audio_frame_queue mdct sinewin"1833nellymoser_encoder_select="audio_frame_queue mdct sinewin"
1832nuv_decoder_select="dsputil lzo"1834nuv_decoder_select="idctdsp lzo"
1833on2avc_decoder_select="mdct"1835on2avc_decoder_select="mdct"
1834opus_decoder_deps="avresample"1836opus_decoder_deps="avresample"
1835png_decoder_deps="zlib"1837png_decoder_deps="zlib"
1836png_encoder_deps="zlib"1838png_encoder_deps="zlib"
1837png_encoder_select="huffyuvencdsp"1839png_encoder_select="huffyuvencdsp"
1838prores_decoder_select="dsputil"1840prores_decoder_select="idctdsp"
1839prores_encoder_select="dsputil"1841prores_encoder_select="dsputil"
1840qcelp_decoder_select="lsp"1842qcelp_decoder_select="lsp"
1841qdm2_decoder_select="mdct rdft mpegaudiodsp"1843qdm2_decoder_select="mdct rdft mpegaudiodsp"
@@ -1888,7 +1890,7 @@ wmav2_encoder_select="mdct sinewin" · 46 unmodified lines
1888wmavoice_decoder_select="lsp rdft dct mdct sinewin"1890wmavoice_decoder_select="lsp rdft dct mdct sinewin"
1889wmv1_decoder_select="h263_decoder"1891wmv1_decoder_select="h263_decoder"
1890wmv1_encoder_select="h263_encoder"1892wmv1_encoder_select="h263_encoder"
1891wmv2_decoder_select="blockdsp h263_decoder intrax8 videodsp"1893wmv2_decoder_select="blockdsp h263_decoder idctdsp intrax8 videodsp"
1892wmv2_encoder_select="h263_encoder"1894wmv2_encoder_select="h263_encoder"
1893wmv3_decoder_select="vc1_decoder"1895wmv3_decoder_select="vc1_decoder"
1894wmv3image_decoder_select="wmv3_decoder"1896wmv3image_decoder_select="wmv3_decoder"
doc/optimization.txt+0−3
@@ -136,9 +136,6 @@ dct_unquantize_mpeg2 · 135 unmodified lines
136dct_unquantize_h263136dct_unquantize_h263
137 Used in MPEG-4/H.263 en/decoding.137 Used in MPEG-4/H.263 en/decoding.
138 138
139FIXME remaining functions?
140BTW, most of these functions are in dsputil.c/.h, some are in mpegvideo.c/.h.
141
142 139
143 140
144Alignment:141Alignment:
libavcodec/Makefile+3−2
@@ -33,9 +33,8 @@ OBJS-$(CONFIG_BLOCKDSP) += blockdsp.o · 32 unmodified lines
33OBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o33OBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o
34OBJS-$(CONFIG_CABAC) += cabac.o34OBJS-$(CONFIG_CABAC) += cabac.o
35OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o35OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
36OBJS-$(CONFIG_DSPUTIL) += dsputil.o
36OBJS-$(CONFIG_DXVA2) += dxva2.o37OBJS-$(CONFIG_DXVA2) += dxva2.o
37OBJS-$(CONFIG_DSPUTIL) += dsputil.o faanidct.o \
38 simple_idct.o jrevdct.o
39OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o38OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o
40OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o39OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o
41FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o40FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o
@@ -51,6 +50,8 @@ OBJS-$(CONFIG_HPELDSP) += hpeldsp.o · 9 unmodified lines
51OBJS-$(CONFIG_HUFFMAN) += huffman.o50OBJS-$(CONFIG_HUFFMAN) += huffman.o
52OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o51OBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o
53OBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o52OBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o
53OBJS-$(CONFIG_IDCTDSP) += idctdsp.o faanidct.o \
54 simple_idct.o jrevdct.o
54OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o55OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o
55OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o56OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o
56OBJS-$(CONFIG_LPC) += lpc.o57OBJS-$(CONFIG_LPC) += lpc.o
libavcodec/aic.c+11−12
@@ -24,10 +24,10 @@ · 23 unmodified lines
24 24
25#include "avcodec.h"25#include "avcodec.h"
26#include "bytestream.h"26#include "bytestream.h"
27#include "dsputil.h"
28#include "internal.h"27#include "internal.h"
29#include "get_bits.h"28#include "get_bits.h"
30#include "golomb.h"29#include "golomb.h"
30#include "idctdsp.h"
31#include "unary.h"31#include "unary.h"
32 32
33#define AIC_HDR_SIZE 2433#define AIC_HDR_SIZE 24
@@ -139,7 +139,7 @@ static const uint8_t *aic_scan[NUM_BANDS] = { · 105 unmodified lines
139typedef struct AICContext {139typedef struct AICContext {
140 AVCodecContext *avctx;140 AVCodecContext *avctx;
141 AVFrame *frame;141 AVFrame *frame;
142 DSPContext dsp;142 IDCTDSPContext idsp;
143 ScanTable scantable;143 ScanTable scantable;
144 144
145 int num_x_slices;145 int num_x_slices;
@@ -336,16 +336,15 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y, · 190 unmodified lines
336 recombine_block_il(ctx->block, ctx->scantable.permutated,336 recombine_block_il(ctx->block, ctx->scantable.permutated,
337 &base_y, &ext_y, blk);337 &base_y, &ext_y, blk);
338 unquant_block(ctx->block, ctx->quant);338 unquant_block(ctx->block, ctx->quant);
339 ctx->dsp.idct(ctx->block);339 ctx->idsp.idct(ctx->block);
340 340
341 if (!ctx->interlaced) {341 if (!ctx->interlaced) {
342 dst = Y + (blk >> 1) * 8 * ystride + (blk & 1) * 8;342 dst = Y + (blk >> 1) * 8 * ystride + (blk & 1) * 8;
343 ctx->dsp.put_signed_pixels_clamped(ctx->block, dst,343 ctx->idsp.put_signed_pixels_clamped(ctx->block, dst, ystride);
344 ystride);
345 } else {344 } else {
346 dst = Y + (blk & 1) * 8 + (blk >> 1) * ystride;345 dst = Y + (blk & 1) * 8 + (blk >> 1) * ystride;
347 ctx->dsp.put_signed_pixels_clamped(ctx->block, dst,346 ctx->idsp.put_signed_pixels_clamped(ctx->block, dst,
348 ystride * 2);347 ystride * 2);
349 }348 }
350 }349 }
351 Y += 16;350 Y += 16;
@@ -354,9 +353,9 @@ static int aic_decode_slice(AICContext *ctx, int mb_x, int mb_y, · 2 unmodified lines
354 recombine_block(ctx->block, ctx->scantable.permutated,353 recombine_block(ctx->block, ctx->scantable.permutated,
355 &base_c, &ext_c);354 &base_c, &ext_c);
356 unquant_block(ctx->block, ctx->quant);355 unquant_block(ctx->block, ctx->quant);
357 ctx->dsp.idct(ctx->block);356 ctx->idsp.idct(ctx->block);
358 ctx->dsp.put_signed_pixels_clamped(ctx->block, C[blk],357 ctx->idsp.put_signed_pixels_clamped(ctx->block, C[blk],
359 ctx->frame->linesize[blk + 1]);358 ctx->frame->linesize[blk + 1]);
360 C[blk] += 8;359 C[blk] += 8;
361 }360 }
362 }361 }
@@ -426,11 +425,11 @@ static av_cold int aic_decode_init(AVCodecContext *avctx) · 63 unmodified lines
426 425
427 avctx->pix_fmt = AV_PIX_FMT_YUV420P;426 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
428 427
429 ff_dsputil_init(&ctx->dsp, avctx);428 ff_idctdsp_init(&ctx->idsp, avctx);
430 429
431 for (i = 0; i < 64; i++)430 for (i = 0; i < 64; i++)
432 scan[i] = i;431 scan[i] = i;
433 ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, scan);432 ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, scan);
434 433
435 ctx->mb_width = FFALIGN(avctx->width, 16) >> 4;434 ctx->mb_width = FFALIGN(avctx->width, 16) >> 4;
436 ctx->mb_height = FFALIGN(avctx->height, 16) >> 4;435 ctx->mb_height = FFALIGN(avctx->height, 16) >> 4;
libavcodec/arm/Makefile+13−10
@@ -6,10 +6,7 @@ OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_init_arm.o \ · 5 unmodified lines
6 arm/ac3dsp_arm.o6 arm/ac3dsp_arm.o
7OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_arm.o7OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_arm.o
8OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_arm.o8OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_arm.o
9OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_arm.o \9OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_arm.o
10 arm/dsputil_arm.o \
11 arm/jrevdct_arm.o \
12 arm/simple_idct_arm.o
13OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o \10OBJS-$(CONFIG_FFT) += arm/fft_init_arm.o \
14 arm/fft_fixed_init_arm.o11 arm/fft_fixed_init_arm.o
15OBJS-$(CONFIG_H264CHROMA) += arm/h264chroma_init_arm.o12OBJS-$(CONFIG_H264CHROMA) += arm/h264chroma_init_arm.o
@@ -18,6 +15,10 @@ OBJS-$(CONFIG_H264PRED) += arm/h264pred_init_arm.o · 2 unmodified lines
18OBJS-$(CONFIG_H264QPEL) += arm/h264qpel_init_arm.o15OBJS-$(CONFIG_H264QPEL) += arm/h264qpel_init_arm.o
19OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_arm.o \16OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_arm.o \
20 arm/hpeldsp_arm.o17 arm/hpeldsp_arm.o
18OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_arm.o \
19 arm/idctdsp_arm.o \
20 arm/jrevdct_arm.o \
21 arm/simple_idct_arm.o
21OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o22OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o
22OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o23OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o
23OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o24OBJS-$(CONFIG_NEON_CLOBBER_TEST) += arm/neontest.o
@@ -40,7 +41,7 @@ OBJS-$(CONFIG_RV30_DECODER) += arm/rv34dsp_init_arm.o · 16 unmodified lines
40OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_init_arm.o \41OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_init_arm.o \
41 arm/rv40dsp_init_arm.o42 arm/rv40dsp_init_arm.o
42 43
43ARMV5TE-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_armv5te.o \44ARMV5TE-OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_armv5te.o \
44 arm/simple_idct_armv5te.o45 arm/simple_idct_armv5te.o
45ARMV5TE-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_armv5te.o \46ARMV5TE-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_armv5te.o \
46 arm/mpegvideo_armv5te_s.o47 arm/mpegvideo_armv5te_s.o
@@ -51,11 +52,13 @@ ARMV5TE-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv5te.o · 4 unmodified lines
51 52
52ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o53ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o
53ARMV6-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_armv6.o \54ARMV6-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_armv6.o \
54 arm/dsputil_armv6.o \55 arm/dsputil_armv6.o
55 arm/simple_idct_armv6.o
56ARMV6-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_armv6.o56ARMV6-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_armv6.o
57ARMV6-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_armv6.o \57ARMV6-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_armv6.o \
58 arm/hpeldsp_armv6.o58 arm/hpeldsp_armv6.o
59ARMV6-OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_armv6.o \
60 arm/idctdsp_armv6.o \
61 arm/simple_idct_armv6.o
59ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o62ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o
60 63
61ARMV6-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv6.o64ARMV6-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv6.o
@@ -83,9 +86,6 @@ NEON-OBJS-$(CONFIG_AUDIODSP) += arm/audiodsp_init_neon.o \ · 21 unmodified lines
83 arm/int_neon.o86 arm/int_neon.o
84NEON-OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_neon.o \87NEON-OBJS-$(CONFIG_BLOCKDSP) += arm/blockdsp_init_neon.o \
85 arm/blockdsp_neon.o88 arm/blockdsp_neon.o
86NEON-OBJS-$(CONFIG_DSPUTIL) += arm/dsputil_init_neon.o \
87 arm/dsputil_neon.o \
88 arm/simple_idct_neon.o
89NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o \89NEON-OBJS-$(CONFIG_FFT) += arm/fft_neon.o \
90 arm/fft_fixed_neon.o90 arm/fft_fixed_neon.o
91NEON-OBJS-$(CONFIG_H264CHROMA) += arm/h264cmc_neon.o91NEON-OBJS-$(CONFIG_H264CHROMA) += arm/h264cmc_neon.o
@@ -96,6 +96,9 @@ NEON-OBJS-$(CONFIG_H264QPEL) += arm/h264qpel_neon.o \ · 4 unmodified lines
96 arm/hpeldsp_neon.o96 arm/hpeldsp_neon.o
97NEON-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_neon.o \97NEON-OBJS-$(CONFIG_HPELDSP) += arm/hpeldsp_init_neon.o \
98 arm/hpeldsp_neon.o98 arm/hpeldsp_neon.o
99NEON-OBJS-$(CONFIG_IDCTDSP) += arm/idctdsp_init_neon.o \
100 arm/idctdsp_neon.o \
101 arm/simple_idct_neon.o
99NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \102NEON-OBJS-$(CONFIG_MDCT) += arm/mdct_neon.o \
100 arm/mdct_fixed_neon.o103 arm/mdct_fixed_neon.o
101NEON-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_neon.o104NEON-OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_neon.o
libavcodec/arm/dsputil_arm.h+0−4
@@ -24,11 +24,7 @@ · 23 unmodified lines
24#include "libavcodec/avcodec.h"24#include "libavcodec/avcodec.h"
25#include "libavcodec/dsputil.h"25#include "libavcodec/dsputil.h"
26 26
27void ff_dsputil_init_armv5te(DSPContext *c, AVCodecContext *avctx,
28 unsigned high_bit_depth);
29void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx,27void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx,
30 unsigned high_bit_depth);28 unsigned high_bit_depth);
31void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx,
32 unsigned high_bit_depth);
33 29
34#endif /* AVCODEC_ARM_DSPUTIL_ARM_H */30#endif /* AVCODEC_ARM_DSPUTIL_ARM_H */
libavcodec/arm/dsputil_armv6.S+0−27
@@ -20,33 +20,6 @@ · 19 unmodified lines
20 20
21#include "libavutil/arm/asm.S"21#include "libavutil/arm/asm.S"
22 22
23function ff_add_pixels_clamped_armv6, export=1
24 push {r4-r8,lr}
25 mov r3, #8
261:
27 ldm r0!, {r4,r5,r12,lr}
28 ldrd r6, r7, [r1]
29 pkhbt r8, r4, r5, lsl #16
30 pkhtb r5, r5, r4, asr #16
31 pkhbt r4, r12, lr, lsl #16
32 pkhtb lr, lr, r12, asr #16
33 pld [r1, r2]
34 uxtab16 r8, r8, r6
35 uxtab16 r5, r5, r6, ror #8
36 uxtab16 r4, r4, r7
37 uxtab16 lr, lr, r7, ror #8
38 usat16 r8, #8, r8
39 usat16 r5, #8, r5
40 usat16 r4, #8, r4
41 usat16 lr, #8, lr
42 orr r6, r8, r5, lsl #8
43 orr r7, r4, lr, lsl #8
44 subs r3, r3, #1
45 strd_post r6, r7, r1, r2
46 bgt 1b
47 pop {r4-r8,pc}
48endfunc
49
50function ff_get_pixels_armv6, export=123function ff_get_pixels_armv6, export=1
51 pld [r1, r2]24 pld [r1, r2]
52 push {r4-r8, lr}25 push {r4-r8, lr}
libavcodec/arm/dsputil_init_arm.c+0−60
@@ -28,71 +28,11 @@ · 27 unmodified lines
28#include "libavcodec/dsputil.h"28#include "libavcodec/dsputil.h"
29#include "dsputil_arm.h"29#include "dsputil_arm.h"
30 30
31void ff_j_rev_dct_arm(int16_t *data);
32void ff_simple_idct_arm(int16_t *data);
33
34/* XXX: local hack */
35static void (*ff_put_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
36static void (*ff_add_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
37
38void ff_add_pixels_clamped_arm(const int16_t *block, uint8_t *dest,
39 int line_size);
40
41/* XXX: those functions should be suppressed ASAP when all IDCTs are
42 * converted */
43static void j_rev_dct_arm_put(uint8_t *dest, int line_size, int16_t *block)
44{
45 ff_j_rev_dct_arm(block);
46 ff_put_pixels_clamped(block, dest, line_size);
47}
48
49static void j_rev_dct_arm_add(uint8_t *dest, int line_size, int16_t *block)
50{
51 ff_j_rev_dct_arm(block);
52 ff_add_pixels_clamped(block, dest, line_size);
53}
54
55static void simple_idct_arm_put(uint8_t *dest, int line_size, int16_t *block)
56{
57 ff_simple_idct_arm(block);
58 ff_put_pixels_clamped(block, dest, line_size);
59}
60
61static void simple_idct_arm_add(uint8_t *dest, int line_size, int16_t *block)
62{
63 ff_simple_idct_arm(block);
64 ff_add_pixels_clamped(block, dest, line_size);
65}
66
67av_cold void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,31av_cold void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx,
68 unsigned high_bit_depth)32 unsigned high_bit_depth)
69{33{
70 int cpu_flags = av_get_cpu_flags();34 int cpu_flags = av_get_cpu_flags();
71 35
72 ff_put_pixels_clamped = c->put_pixels_clamped;
73 ff_add_pixels_clamped = c->add_pixels_clamped;
74
75 if (!high_bit_depth) {
76 if (avctx->idct_algo == FF_IDCT_AUTO ||
77 avctx->idct_algo == FF_IDCT_ARM) {
78 c->idct_put = j_rev_dct_arm_put;
79 c->idct_add = j_rev_dct_arm_add;
80 c->idct = ff_j_rev_dct_arm;
81 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
82 } else if (avctx->idct_algo == FF_IDCT_SIMPLEARM) {
83 c->idct_put = simple_idct_arm_put;
84 c->idct_add = simple_idct_arm_add;
85 c->idct = ff_simple_idct_arm;
86 c->idct_permutation_type = FF_NO_IDCT_PERM;
87 }
88 }
89
90 c->add_pixels_clamped = ff_add_pixels_clamped_arm;
91
92 if (have_armv5te(cpu_flags))
93 ff_dsputil_init_armv5te(c, avctx, high_bit_depth);
94 if (have_armv6(cpu_flags))36 if (have_armv6(cpu_flags))
95 ff_dsputil_init_armv6(c, avctx, high_bit_depth);37 ff_dsputil_init_armv6(c, avctx, high_bit_depth);
96 if (have_neon(cpu_flags))
97 ff_dsputil_init_neon(c, avctx, high_bit_depth);
98}38}
libavcodec/arm/dsputil_init_armv6.c+0−18
@@ -26,13 +26,6 @@ · 25 unmodified lines
26#include "libavcodec/mpegvideo.h"26#include "libavcodec/mpegvideo.h"
27#include "dsputil_arm.h"27#include "dsputil_arm.h"
28 28
29void ff_simple_idct_armv6(int16_t *data);
30void ff_simple_idct_put_armv6(uint8_t *dest, int line_size, int16_t *data);
31void ff_simple_idct_add_armv6(uint8_t *dest, int line_size, int16_t *data);
32
33void ff_add_pixels_clamped_armv6(const int16_t *block, uint8_t *pixels,
34 int line_size);
35
36void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels, int stride);29void ff_get_pixels_armv6(int16_t *block, const uint8_t *pixels, int stride);
37void ff_diff_pixels_armv6(int16_t *block, const uint8_t *s1,30void ff_diff_pixels_armv6(int16_t *block, const uint8_t *s1,
38 const uint8_t *s2, int stride);31 const uint8_t *s2, int stride);
@@ -56,17 +49,6 @@ int ff_pix_sum_armv6(uint8_t *pix, int line_size); · 17 unmodified lines
56av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx,49av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx,
57 unsigned high_bit_depth)50 unsigned high_bit_depth)
58{51{
59 if (!high_bit_depth) {
60 if (avctx->idct_algo == FF_IDCT_AUTO ||
61 avctx->idct_algo == FF_IDCT_SIMPLEARMV6) {
62 c->idct_put = ff_simple_idct_put_armv6;
63 c->idct_add = ff_simple_idct_add_armv6;
64 c->idct = ff_simple_idct_armv6;
65 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
66 }
67 }
68 c->add_pixels_clamped = ff_add_pixels_clamped_armv6;
69
70 if (!high_bit_depth)52 if (!high_bit_depth)
71 c->get_pixels = ff_get_pixels_armv6;53 c->get_pixels = ff_get_pixels_armv6;
72 c->diff_pixels = ff_diff_pixels_armv6;54 c->diff_pixels = ff_diff_pixels_armv6;
libavcodec/arm/idctdsp_arm.Srenamed from libavcodec/arm/dsputil_arm.S+1−1
@@ -1,5 +1,5 @@
1@1@
2@ ARMv4 optimized DSP utils2@ ARMv4-optimized IDCT functions
3@ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp>3@ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
4@4@
5@ This file is part of Libav.5@ This file is part of Libav.
libavcodec/arm/idctdsp_arm.h+34−0
@@ -0,0 +1,34 @@
1/*
2 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3 *
4 * This file is part of Libav.
5 *
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_ARM_IDCTDSP_ARM_H
22#define AVCODEC_ARM_IDCTDSP_ARM_H
23
24#include "libavcodec/avcodec.h"
25#include "libavcodec/idctdsp.h"
26
27void ff_idctdsp_init_armv5te(IDCTDSPContext *c, AVCodecContext *avctx,
28 unsigned high_bit_depth);
29void ff_idctdsp_init_armv6(IDCTDSPContext *c, AVCodecContext *avctx,
30 unsigned high_bit_depth);
31void ff_idctdsp_init_neon(IDCTDSPContext *c, AVCodecContext *avctx,
32 unsigned high_bit_depth);
33
34#endif /* AVCODEC_ARM_IDCTDSP_ARM_H */
libavcodec/arm/idctdsp_armv6.S+48−0
@@ -0,0 +1,48 @@
1/*
2 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3 *
4 * This file is part of Libav.
5 *
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavutil/arm/asm.S"
22
23function ff_add_pixels_clamped_armv6, export=1
24 push {r4-r8,lr}
25 mov r3, #8
261:
27 ldm r0!, {r4,r5,r12,lr}
28 ldrd r6, r7, [r1]
29 pkhbt r8, r4, r5, lsl #16
30 pkhtb r5, r5, r4, asr #16
31 pkhbt r4, r12, lr, lsl #16
32 pkhtb lr, lr, r12, asr #16
33 pld [r1, r2]
34 uxtab16 r8, r8, r6
35 uxtab16 r5, r5, r6, ror #8
36 uxtab16 r4, r4, r7
37 uxtab16 lr, lr, r7, ror #8
38 usat16 r8, #8, r8
39 usat16 r5, #8, r5
40 usat16 r4, #8, r4
41 usat16 lr, #8, lr
42 orr r6, r8, r5, lsl #8
43 orr r7, r4, lr, lsl #8
44 subs r3, r3, #1
45 strd_post r6, r7, r1, r2
46 bgt 1b
47 pop {r4-r8,pc}
48endfunc
libavcodec/arm/idctdsp_init_arm.c+98−0
@@ -0,0 +1,98 @@
1/*
2 * ARM-optimized IDCT functions
3 * Copyright (c) 2001 Lionel Ulmer
4 *
5 * This file is part of Libav.
6 *
7 * Libav is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * Libav is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <stdint.h>
23
24#include "libavutil/attributes.h"
25#include "libavutil/cpu.h"
26#include "libavutil/arm/cpu.h"
27#include "libavcodec/avcodec.h"
28#include "libavcodec/idctdsp.h"
29#include "idctdsp_arm.h"
30
31void ff_j_rev_dct_arm(int16_t *data);
32void ff_simple_idct_arm(int16_t *data);
33
34/* XXX: local hack */
35static void (*ff_put_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
36static void (*ff_add_pixels_clamped)(const int16_t *block, uint8_t *pixels, int line_size);
37
38void ff_add_pixels_clamped_arm(const int16_t *block, uint8_t *dest,
39 int line_size);
40
41/* XXX: those functions should be suppressed ASAP when all IDCTs are
42 * converted */
43static void j_rev_dct_arm_put(uint8_t *dest, int line_size, int16_t *block)
44{
45 ff_j_rev_dct_arm(block);
46 ff_put_pixels_clamped(block, dest, line_size);
47}
48
49static void j_rev_dct_arm_add(uint8_t *dest, int line_size, int16_t *block)
50{
51 ff_j_rev_dct_arm(block);
52 ff_add_pixels_clamped(block, dest, line_size);
53}
54
55static void simple_idct_arm_put(uint8_t *dest, int line_size, int16_t *block)
56{
57 ff_simple_idct_arm(block);
58 ff_put_pixels_clamped(block, dest, line_size);
59}
60
61static void simple_idct_arm_add(uint8_t *dest, int line_size, int16_t *block)
62{
63 ff_simple_idct_arm(block);
64 ff_add_pixels_clamped(block, dest, line_size);
65}
66
67av_cold void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
68 unsigned high_bit_depth)
69{
70 int cpu_flags = av_get_cpu_flags();
71
72 ff_put_pixels_clamped = c->put_pixels_clamped;
73 ff_add_pixels_clamped = c->add_pixels_clamped;
74
75 if (!high_bit_depth) {
76 if (avctx->idct_algo == FF_IDCT_AUTO ||
77 avctx->idct_algo == FF_IDCT_ARM) {
78 c->idct_put = j_rev_dct_arm_put;
79 c->idct_add = j_rev_dct_arm_add;
80 c->idct = ff_j_rev_dct_arm;
81 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
82 } else if (avctx->idct_algo == FF_IDCT_SIMPLEARM) {
83 c->idct_put = simple_idct_arm_put;
84 c->idct_add = simple_idct_arm_add;
85 c->idct = ff_simple_idct_arm;
86 c->idct_permutation_type = FF_NO_IDCT_PERM;
87 }
88 }
89
90 c->add_pixels_clamped = ff_add_pixels_clamped_arm;
91
92 if (have_armv5te(cpu_flags))
93 ff_idctdsp_init_armv5te(c, avctx, high_bit_depth);
94 if (have_armv6(cpu_flags))
95 ff_idctdsp_init_armv6(c, avctx, high_bit_depth);
96 if (have_neon(cpu_flags))
97 ff_idctdsp_init_neon(c, avctx, high_bit_depth);
98}
libavcodec/arm/idctdsp_init_armv5te.crenamed from libavcodec/arm/dsputil_init_armv5te.c+3−3
@@ -22,14 +22,14 @@ · 21 unmodified lines
22 22
23#include "libavutil/attributes.h"23#include "libavutil/attributes.h"
24#include "libavcodec/avcodec.h"24#include "libavcodec/avcodec.h"
25#include "libavcodec/dsputil.h"25#include "libavcodec/idctdsp.h"
26#include "dsputil_arm.h"26#include "idctdsp_arm.h"
27 27
28void ff_simple_idct_armv5te(int16_t *data);28void ff_simple_idct_armv5te(int16_t *data);
29void ff_simple_idct_put_armv5te(uint8_t *dest, int line_size, int16_t *data);29void ff_simple_idct_put_armv5te(uint8_t *dest, int line_size, int16_t *data);
30void ff_simple_idct_add_armv5te(uint8_t *dest, int line_size, int16_t *data);30void ff_simple_idct_add_armv5te(uint8_t *dest, int line_size, int16_t *data);
31 31
32av_cold void ff_dsputil_init_armv5te(DSPContext *c, AVCodecContext *avctx,32av_cold void ff_idctdsp_init_armv5te(IDCTDSPContext *c, AVCodecContext *avctx,
33 unsigned high_bit_depth)33 unsigned high_bit_depth)
34{34{
35 if (!high_bit_depth &&35 if (!high_bit_depth &&
libavcodec/arm/idctdsp_init_armv6.c+48−0
@@ -0,0 +1,48 @@
1/*
2 * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
3 *
4 * This file is part of Libav.
5 *
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <stdint.h>
22
23#include "libavutil/attributes.h"
24#include "libavcodec/avcodec.h"
25#include "libavcodec/idctdsp.h"
26#include "idctdsp_arm.h"
27
28void ff_simple_idct_armv6(int16_t *data);
29void ff_simple_idct_put_armv6(uint8_t *dest, int line_size, int16_t *data);
30void ff_simple_idct_add_armv6(uint8_t *dest, int line_size, int16_t *data);
31
32void ff_add_pixels_clamped_armv6(const int16_t *block, uint8_t *pixels,
33 int line_size);
34
35av_cold void ff_idctdsp_init_armv6(IDCTDSPContext *c, AVCodecContext *avctx,
36 unsigned high_bit_depth)
37{
38 if (!high_bit_depth) {
39 if (avctx->idct_algo == FF_IDCT_AUTO ||
40 avctx->idct_algo == FF_IDCT_SIMPLEARMV6) {
41 c->idct_put = ff_simple_idct_put_armv6;
42 c->idct_add = ff_simple_idct_add_armv6;
43 c->idct = ff_simple_idct_armv6;
44 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
45 }
46 }
47 c->add_pixels_clamped = ff_add_pixels_clamped_armv6;
48}
libavcodec/arm/idctdsp_init_neon.crenamed from libavcodec/arm/dsputil_init_neon.c+4−4
@@ -1,5 +1,5 @@
1/*1/*
2 * ARM NEON optimised DSP functions2 * ARM-NEON-optimized IDCT functions
3 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>3 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
4 *4 *
5 * This file is part of Libav.5 * This file is part of Libav.
@@ -23,8 +23,8 @@ · 17 unmodified lines
23 23
24#include "libavutil/attributes.h"24#include "libavutil/attributes.h"
25#include "libavcodec/avcodec.h"25#include "libavcodec/avcodec.h"
26#include "libavcodec/dsputil.h"26#include "libavcodec/idctdsp.h"
27#include "dsputil_arm.h"27#include "idctdsp_arm.h"
28 28
29void ff_simple_idct_neon(int16_t *data);29void ff_simple_idct_neon(int16_t *data);
30void ff_simple_idct_put_neon(uint8_t *dest, int line_size, int16_t *data);30void ff_simple_idct_put_neon(uint8_t *dest, int line_size, int16_t *data);
@@ -34,7 +34,7 @@ void ff_add_pixels_clamped_neon(const int16_t *, uint8_t *, int); · 3 unmodified lines
34void ff_put_pixels_clamped_neon(const int16_t *, uint8_t *, int);34void ff_put_pixels_clamped_neon(const int16_t *, uint8_t *, int);
35void ff_put_signed_pixels_clamped_neon(const int16_t *, uint8_t *, int);35void ff_put_signed_pixels_clamped_neon(const int16_t *, uint8_t *, int);
36 36
37av_cold void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx,37av_cold void ff_idctdsp_init_neon(IDCTDSPContext *c, AVCodecContext *avctx,
38 unsigned high_bit_depth)38 unsigned high_bit_depth)
39{39{
40 if (!high_bit_depth) {40 if (!high_bit_depth) {
libavcodec/arm/idctdsp_neon.Srenamed from libavcodec/arm/dsputil_neon.S+1−1
@@ -1,5 +1,5 @@
1/*1/*
2 * ARM NEON optimised DSP functions2 * ARM-NEON-optimized IDCT functions
3 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>3 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
4 *4 *
5 * This file is part of Libav.5 * This file is part of Libav.
libavcodec/asv.c+0−1
@@ -84,7 +84,6 @@ av_cold void ff_asv_common_init(AVCodecContext *avctx) { · 83 unmodified lines
84 ASV1Context * const a = avctx->priv_data;84 ASV1Context * const a = avctx->priv_data;
85 85
86 ff_bswapdsp_init(&a->bbdsp);86 ff_bswapdsp_init(&a->bbdsp);
87 ff_dsputil_init(&a->dsp, avctx);
88 87
89 a->mb_width = (avctx->width + 15) / 16;88 a->mb_width = (avctx->width + 15) / 16;
90 a->mb_height = (avctx->height + 15) / 16;89 a->mb_height = (avctx->height + 15) / 16;
libavcodec/asv.h+2−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
34#include "blockdsp.h"34#include "blockdsp.h"
35#include "bswapdsp.h"35#include "bswapdsp.h"
36#include "dsputil.h"36#include "dsputil.h"
37#include "idctdsp.h"
37#include "get_bits.h"38#include "get_bits.h"
38#include "put_bits.h"39#include "put_bits.h"
39 40
@@ -42,6 +43,7 @@ typedef struct ASV1Context{ · 2 unmodified lines
42 BlockDSPContext bdsp;43 BlockDSPContext bdsp;
43 BswapDSPContext bbdsp;44 BswapDSPContext bbdsp;
44 DSPContext dsp;45 DSPContext dsp;
46 IDCTDSPContext idsp;
45 PutBitContext pb;47 PutBitContext pb;
46 GetBitContext gb;48 GetBitContext gb;
47 ScanTable scantable;49 ScanTable scantable;
libavcodec/asvdec.c+9−7
@@ -30,6 +30,7 @@ · 29 unmodified lines
30#include "avcodec.h"30#include "avcodec.h"
31#include "blockdsp.h"31#include "blockdsp.h"
32#include "put_bits.h"32#include "put_bits.h"
33#include "idctdsp.h"
33#include "internal.h"34#include "internal.h"
34#include "mathops.h"35#include "mathops.h"
35#include "mpeg12data.h"36#include "mpeg12data.h"
@@ -190,14 +191,14 @@ static inline void idct_put(ASV1Context *a, AVFrame *frame, int mb_x, int mb_y) · 154 unmodified lines
190 uint8_t *dest_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8;191 uint8_t *dest_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8;
191 uint8_t *dest_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8;192 uint8_t *dest_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8;
192 193
193 a->dsp.idct_put(dest_y , linesize, block[0]);194 a->idsp.idct_put(dest_y, linesize, block[0]);
194 a->dsp.idct_put(dest_y + 8, linesize, block[1]);195 a->idsp.idct_put(dest_y + 8, linesize, block[1]);
195 a->dsp.idct_put(dest_y + 8*linesize , linesize, block[2]);196 a->idsp.idct_put(dest_y + 8 * linesize, linesize, block[2]);
196 a->dsp.idct_put(dest_y + 8*linesize + 8, linesize, block[3]);197 a->idsp.idct_put(dest_y + 8 * linesize + 8, linesize, block[3]);
197 198
198 if (!(a->avctx->flags&CODEC_FLAG_GRAY)) {199 if (!(a->avctx->flags&CODEC_FLAG_GRAY)) {
199 a->dsp.idct_put(dest_cb, frame->linesize[1], block[4]);200 a->idsp.idct_put(dest_cb, frame->linesize[1], block[4]);
200 a->dsp.idct_put(dest_cr, frame->linesize[2], block[5]);201 a->idsp.idct_put(dest_cr, frame->linesize[2], block[5]);
201 }202 }
202}203}
203 204
@@ -283,8 +284,9 @@ static av_cold int decode_init(AVCodecContext *avctx) · 79 unmodified lines
283 284
284 ff_asv_common_init(avctx);285 ff_asv_common_init(avctx);
285 ff_blockdsp_init(&a->bdsp, avctx);286 ff_blockdsp_init(&a->bdsp, avctx);
287 ff_idctdsp_init(&a->idsp, avctx);
286 init_vlcs(a);288 init_vlcs(a);
287 ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_asv_scantab);289 ff_init_scantable(a->idsp.idct_permutation, &a->scantable, ff_asv_scantab);
288 avctx->pix_fmt = AV_PIX_FMT_YUV420P;290 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
289 291
290 a->inv_qscale = avctx->extradata[0];292 a->inv_qscale = avctx->extradata[0];
libavcodec/asvenc.c+1−0
@@ -247,6 +247,7 @@ static av_cold int encode_init(AVCodecContext *avctx){ · 246 unmodified lines
247 avctx->coded_frame->key_frame = 1;247 avctx->coded_frame->key_frame = 1;
248 248
249 ff_asv_common_init(avctx);249 ff_asv_common_init(avctx);
250 ff_dsputil_init(&a->dsp, avctx);
250 251
251 if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE;252 if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE;
252 253
libavcodec/cavs.c+4−3
@@ -29,6 +29,7 @@ · 28 unmodified lines
29#include "get_bits.h"29#include "get_bits.h"
30#include "golomb.h"30#include "golomb.h"
31#include "h264chroma.h"31#include "h264chroma.h"
32#include "idctdsp.h"
32#include "mathops.h"33#include "mathops.h"
33#include "qpeldsp.h"34#include "qpeldsp.h"
34#include "cavs.h"35#include "cavs.h"
@@ -760,13 +761,13 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) · 725 unmodified lines
760 AVSContext *h = avctx->priv_data;761 AVSContext *h = avctx->priv_data;
761 762
762 ff_blockdsp_init(&h->bdsp, avctx);763 ff_blockdsp_init(&h->bdsp, avctx);
763 ff_dsputil_init(&h->dsp, avctx);
764 ff_h264chroma_init(&h->h264chroma, 8);764 ff_h264chroma_init(&h->h264chroma, 8);
765 ff_idctdsp_init(&h->idsp, avctx);
765 ff_videodsp_init(&h->vdsp, 8);766 ff_videodsp_init(&h->vdsp, 8);
766 ff_cavsdsp_init(&h->cdsp, avctx);767 ff_cavsdsp_init(&h->cdsp, avctx);
767 ff_init_scantable_permutation(h->dsp.idct_permutation,768 ff_init_scantable_permutation(h->idsp.idct_permutation,
768 h->cdsp.idct_perm);769 h->cdsp.idct_perm);
769 ff_init_scantable(h->dsp.idct_permutation, &h->scantable, ff_zigzag_direct);770 ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct);
770 771
771 h->avctx = avctx;772 h->avctx = avctx;
772 avctx->pix_fmt = AV_PIX_FMT_YUV420P;773 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
libavcodec/cavs.h+2−2
@@ -24,8 +24,8 @@ · 23 unmodified lines
24 24
25#include "cavsdsp.h"25#include "cavsdsp.h"
26#include "blockdsp.h"26#include "blockdsp.h"
27#include "dsputil.h"
28#include "h264chroma.h"27#include "h264chroma.h"
28#include "idctdsp.h"
29#include "get_bits.h"29#include "get_bits.h"
30#include "videodsp.h"30#include "videodsp.h"
31 31
@@ -162,9 +162,9 @@ typedef struct AVSFrame { · 130 unmodified lines
162 162
163typedef struct AVSContext {163typedef struct AVSContext {
164 AVCodecContext *avctx;164 AVCodecContext *avctx;
165 DSPContext dsp;
166 BlockDSPContext bdsp;165 BlockDSPContext bdsp;
167 H264ChromaContext h264chroma;166 H264ChromaContext h264chroma;
167 IDCTDSPContext idsp;
168 VideoDSPContext vdsp;168 VideoDSPContext vdsp;
169 CAVSDSPContext cdsp;169 CAVSDSPContext cdsp;
170 GetBitContext gb;170 GetBitContext gb;
libavcodec/cavsdsp.c+1−1
@@ -24,7 +24,7 @@ · 23 unmodified lines
24 24
25#include <stdio.h>25#include <stdio.h>
26 26
27#include "dsputil.h"27#include "idctdsp.h"
28#include "mathops.h"28#include "mathops.h"
29#include "cavsdsp.h"29#include "cavsdsp.h"
30#include "libavutil/common.h"30#include "libavutil/common.h"
libavcodec/dnxhddec.c+26−26
@@ -28,7 +28,7 @@ · 27 unmodified lines
28#include "blockdsp.h"28#include "blockdsp.h"
29#include "get_bits.h"29#include "get_bits.h"
30#include "dnxhddata.h"30#include "dnxhddata.h"
31#include "dsputil.h"31#include "idctdsp.h"
32#include "internal.h"32#include "internal.h"
33 33
34typedef struct DNXHDContext {34typedef struct DNXHDContext {
@@ -42,7 +42,7 @@ typedef struct DNXHDContext { · 7 unmodified lines
42 int cur_field; ///< current interlaced field42 int cur_field; ///< current interlaced field
43 VLC ac_vlc, dc_vlc, run_vlc;43 VLC ac_vlc, dc_vlc, run_vlc;
44 int last_dc[3];44 int last_dc[3];
45 DSPContext dsp;45 IDCTDSPContext idsp;
46 DECLARE_ALIGNED(16, int16_t, blocks)[12][64];46 DECLARE_ALIGNED(16, int16_t, blocks)[12][64];
47 ScanTable scantable;47 ScanTable scantable;
48 const CIDEntry *cid_table;48 const CIDEntry *cid_table;
@@ -95,7 +95,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid) · 46 unmodified lines
95 ctx->cid_table->run_bits, 1, 1,95 ctx->cid_table->run_bits, 1, 1,
96 ctx->cid_table->run_codes, 2, 2, 0);96 ctx->cid_table->run_codes, 2, 2, 0);
97 97
98 ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable,98 ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable,
99 ff_zigzag_direct);99 ff_zigzag_direct);
100 ctx->cid = cid;100 ctx->cid = cid;
101 }101 }
@@ -136,7 +136,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, · 34 unmodified lines
136 ctx->avctx->bits_per_raw_sample = 10;136 ctx->avctx->bits_per_raw_sample = 10;
137 if (ctx->bit_depth != 10) {137 if (ctx->bit_depth != 10) {
138 ff_blockdsp_init(&ctx->bdsp, ctx->avctx);138 ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
139 ff_dsputil_init(&ctx->dsp, ctx->avctx);139 ff_idctdsp_init(&ctx->idsp, ctx->avctx);
140 ctx->bit_depth = 10;140 ctx->bit_depth = 10;
141 ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;141 ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;
142 }142 }
@@ -146,7 +146,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, · 3 unmodified lines
146 ctx->avctx->bits_per_raw_sample = 10;146 ctx->avctx->bits_per_raw_sample = 10;
147 if (ctx->bit_depth != 10) {147 if (ctx->bit_depth != 10) {
148 ff_blockdsp_init(&ctx->bdsp, ctx->avctx);148 ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
149 ff_dsputil_init(&ctx->dsp, ctx->avctx);149 ff_idctdsp_init(&ctx->idsp, ctx->avctx);
150 ctx->bit_depth = 10;150 ctx->bit_depth = 10;
151 ctx->decode_dct_block = dnxhd_decode_dct_block_10;151 ctx->decode_dct_block = dnxhd_decode_dct_block_10;
152 }152 }
@@ -155,7 +155,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, · 2 unmodified lines
155 ctx->avctx->bits_per_raw_sample = 8;155 ctx->avctx->bits_per_raw_sample = 8;
156 if (ctx->bit_depth != 8) {156 if (ctx->bit_depth != 8) {
157 ff_blockdsp_init(&ctx->bdsp, ctx->avctx);157 ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
158 ff_dsputil_init(&ctx->dsp, ctx->avctx);158 ff_idctdsp_init(&ctx->idsp, ctx->avctx);
159 ctx->bit_depth = 8;159 ctx->bit_depth = 8;
160 ctx->decode_dct_block = dnxhd_decode_dct_block_8;160 ctx->decode_dct_block = dnxhd_decode_dct_block_8;
161 }161 }
@@ -340,34 +340,34 @@ static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame, · 178 unmodified lines
340 dct_y_offset = dct_linesize_luma << 3;340 dct_y_offset = dct_linesize_luma << 3;
341 dct_x_offset = 8 << shift1;341 dct_x_offset = 8 << shift1;
342 if (!ctx->is_444) {342 if (!ctx->is_444) {
343 ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);343 ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
344 ctx->dsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);344 ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
345 ctx->dsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]);345 ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[4]);
346 ctx->dsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]);346 ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]);
347 347
348 if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {348 if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
349 dct_y_offset = dct_linesize_chroma << 3;349 dct_y_offset = dct_linesize_chroma << 3;
350 ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);350 ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
351 ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]);351 ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[3]);
352 ctx->dsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]);352 ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]);
353 ctx->dsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]);353 ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[7]);
354 }354 }
355 } else {355 } else {
356 ctx->dsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);356 ctx->idsp.idct_put(dest_y, dct_linesize_luma, ctx->blocks[0]);
357 ctx->dsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);357 ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, ctx->blocks[1]);
358 ctx->dsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[6]);358 ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, ctx->blocks[6]);
359 ctx->dsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]);359 ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]);
360 360
361 if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {361 if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
362 dct_y_offset = dct_linesize_chroma << 3;362 dct_y_offset = dct_linesize_chroma << 3;
363 ctx->dsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);363 ctx->idsp.idct_put(dest_u, dct_linesize_chroma, ctx->blocks[2]);
364 ctx->dsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, ctx->blocks[3]);364 ctx->idsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, ctx->blocks[3]);
365 ctx->dsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[8]);365 ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[8]);
366 ctx->dsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[9]);366 ctx->idsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[9]);
367 ctx->dsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[4]);367 ctx->idsp.idct_put(dest_v, dct_linesize_chroma, ctx->blocks[4]);
368 ctx->dsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, ctx->blocks[5]);368 ctx->idsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, ctx->blocks[5]);
369 ctx->dsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[10]);369 ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, ctx->blocks[10]);
370 ctx->dsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[11]);370 ctx->idsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, ctx->blocks[11]);
371 }371 }
372 }372 }
373 373
libavcodec/dnxhdenc.c+5−4
@@ -200,14 +200,14 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) · 199 unmodified lines
200 200
201 if (ctx->cid_table->bit_depth == 8) {201 if (ctx->cid_table->bit_depth == 8) {
202 for (i = 1; i < 64; i++) {202 for (i = 1; i < 64; i++) {
203 int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];203 int j = ctx->m.idsp.idct_permutation[ff_zigzag_direct[i]];
204 weight_matrix[j] = ctx->cid_table->luma_weight[i];204 weight_matrix[j] = ctx->cid_table->luma_weight[i];
205 }205 }
206 ff_convert_matrix(&ctx->m, ctx->qmatrix_l, ctx->qmatrix_l16,206 ff_convert_matrix(&ctx->m, ctx->qmatrix_l, ctx->qmatrix_l16,
207 weight_matrix, ctx->m.intra_quant_bias, 1,207 weight_matrix, ctx->m.intra_quant_bias, 1,
208 ctx->m.avctx->qmax, 1);208 ctx->m.avctx->qmax, 1);
209 for (i = 1; i < 64; i++) {209 for (i = 1; i < 64; i++) {
210 int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];210 int j = ctx->m.idsp.idct_permutation[ff_zigzag_direct[i]];
211 weight_matrix[j] = ctx->cid_table->chroma_weight[i];211 weight_matrix[j] = ctx->cid_table->chroma_weight[i];
212 }212 }
213 ff_convert_matrix(&ctx->m, ctx->qmatrix_c, ctx->qmatrix_c16,213 ff_convert_matrix(&ctx->m, ctx->qmatrix_c, ctx->qmatrix_c16,
@@ -228,7 +228,7 @@ static av_cold int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) · 14 unmodified lines
228 // 10-bit228 // 10-bit
229 for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) {229 for (qscale = 1; qscale <= ctx->m.avctx->qmax; qscale++) {
230 for (i = 1; i < 64; i++) {230 for (i = 1; i < 64; i++) {
231 int j = ctx->m.dsp.idct_permutation[ff_zigzag_direct[i]];231 int j = ctx->m.idsp.idct_permutation[ff_zigzag_direct[i]];
232 232
233 /* The quantization formula from the VC-3 standard is:233 /* The quantization formula from the VC-3 standard is:
234 * quantized = sign(block[i]) * floor(abs(block[i]/s) * p /234 * quantized = sign(block[i]) * floor(abs(block[i]/s) * p /
@@ -308,6 +308,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) · 73 unmodified lines
308 308
309 ff_blockdsp_init(&ctx->bdsp, avctx);309 ff_blockdsp_init(&ctx->bdsp, avctx);
310 ff_dsputil_init(&ctx->m.dsp, avctx);310 ff_dsputil_init(&ctx->m.dsp, avctx);
311 ff_idctdsp_init(&ctx->m.idsp, avctx);
311 ff_dct_common_init(&ctx->m);312 ff_dct_common_init(&ctx->m);
312 if (!ctx->m.dct_quantize)313 if (!ctx->m.dct_quantize)
313 ctx->m.dct_quantize = ff_dct_quantize_c;314 ctx->m.dct_quantize = ff_dct_quantize_c;
@@ -634,7 +635,7 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, · 320 unmodified lines
634 635
635 if (avctx->mb_decision == FF_MB_DECISION_RD || !RC_VARIANCE) {636 if (avctx->mb_decision == FF_MB_DECISION_RD || !RC_VARIANCE) {
636 dnxhd_unquantize_c(ctx, block, i, qscale, last_index);637 dnxhd_unquantize_c(ctx, block, i, qscale, last_index);
637 ctx->m.dsp.idct(block);638 ctx->m.idsp.idct(block);
638 ssd += dnxhd_ssd_block(block, src_block);639 ssd += dnxhd_ssd_block(block, src_block);
639 }640 }
640 }641 }
libavcodec/dsputil.c+1−161
@@ -33,7 +33,6 @@ · 32 unmodified lines
33#include "dsputil.h"33#include "dsputil.h"
34#include "simple_idct.h"34#include "simple_idct.h"
35#include "faandct.h"35#include "faandct.h"
36#include "faanidct.h"
37#include "imgconvert.h"36#include "imgconvert.h"
38#include "mathops.h"37#include "mathops.h"
39#include "mpegvideo.h"38#include "mpegvideo.h"
@@ -48,60 +47,6 @@ uint32_t ff_square_tab[512] = { 0, }; · 8 unmodified lines
48#define BIT_DEPTH 847#define BIT_DEPTH 8
49#include "dsputilenc_template.c"48#include "dsputilenc_template.c"
50 49
51av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
52 const uint8_t *src_scantable)
53{
54 int i, end;
55
56 st->scantable = src_scantable;
57
58 for (i = 0; i < 64; i++) {
59 int j = src_scantable[i];
60 st->permutated[i] = permutation[j];
61 }
62
63 end = -1;
64 for (i = 0; i < 64; i++) {
65 int j = st->permutated[i];
66 if (j > end)
67 end = j;
68 st->raster_end[i] = end;
69 }
70}
71
72av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
73 int idct_permutation_type)
74{
75 int i;
76
77 if (ARCH_X86)
78 if (ff_init_scantable_permutation_x86(idct_permutation,
79 idct_permutation_type))
80 return;
81
82 switch (idct_permutation_type) {
83 case FF_NO_IDCT_PERM:
84 for (i = 0; i < 64; i++)
85 idct_permutation[i] = i;
86 break;
87 case FF_LIBMPEG2_IDCT_PERM:
88 for (i = 0; i < 64; i++)
89 idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
90 break;
91 case FF_TRANSPOSE_IDCT_PERM:
92 for (i = 0; i < 64; i++)
93 idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
94 break;
95 case FF_PARTTRANS_IDCT_PERM:
96 for (i = 0; i < 64; i++)
97 idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
98 break;
99 default:
100 av_log(NULL, AV_LOG_ERROR,
101 "Internal error, IDCT permutation not set\n");
102 }
103}
104
105static int pix_sum_c(uint8_t *pix, int line_size)50static int pix_sum_c(uint8_t *pix, int line_size)
106{51{
107 int s = 0, i, j;52 int s = 0, i, j;
@@ -259,68 +204,6 @@ static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1, · 151 unmodified lines
259 }204 }
260}205}
261 206
262static void put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
263 int line_size)
264{
265 int i;
266
267 /* read the pixels */
268 for (i = 0; i < 8; i++) {
269 pixels[0] = av_clip_uint8(block[0]);
270 pixels[1] = av_clip_uint8(block[1]);
271 pixels[2] = av_clip_uint8(block[2]);
272 pixels[3] = av_clip_uint8(block[3]);
273 pixels[4] = av_clip_uint8(block[4]);
274 pixels[5] = av_clip_uint8(block[5]);
275 pixels[6] = av_clip_uint8(block[6]);
276 pixels[7] = av_clip_uint8(block[7]);
277
278 pixels += line_size;
279 block += 8;
280 }
281}
282
283static void put_signed_pixels_clamped_c(const int16_t *block,
284 uint8_t *restrict pixels,
285 int line_size)
286{
287 int i, j;
288
289 for (i = 0; i < 8; i++) {
290 for (j = 0; j < 8; j++) {
291 if (*block < -128)
292 *pixels = 0;
293 else if (*block > 127)
294 *pixels = 255;
295 else
296 *pixels = (uint8_t) (*block + 128);
297 block++;
298 pixels++;
299 }
300 pixels += (line_size - 8);
301 }
302}
303
304static void add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
305 int line_size)
306{
307 int i;
308
309 /* read the pixels */
310 for (i = 0; i < 8; i++) {
311 pixels[0] = av_clip_uint8(pixels[0] + block[0]);
312 pixels[1] = av_clip_uint8(pixels[1] + block[1]);
313 pixels[2] = av_clip_uint8(pixels[2] + block[2]);
314 pixels[3] = av_clip_uint8(pixels[3] + block[3]);
315 pixels[4] = av_clip_uint8(pixels[4] + block[4]);
316 pixels[5] = av_clip_uint8(pixels[5] + block[5]);
317 pixels[6] = av_clip_uint8(pixels[6] + block[6]);
318 pixels[7] = av_clip_uint8(pixels[7] + block[7]);
319 pixels += line_size;
320 block += 8;
321 }
322}
323
324static int sum_abs_dctelem_c(int16_t *block)207static int sum_abs_dctelem_c(int16_t *block)
325{208{
326 int sum = 0, i;209 int sum = 0, i;
@@ -967,7 +850,7 @@ static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2, · 640 unmodified lines
967 s->dct_unquantize_inter(s, temp, 0, s->qscale);850 s->dct_unquantize_inter(s, temp, 0, s->qscale);
968 }851 }
969 852
970 s->dsp.idct_add(lsrc2, 8, temp);853 s->idsp.idct_add(lsrc2, 8, temp);
971 854
972 distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);855 distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
973 856
@@ -1138,18 +1021,6 @@ WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) · 164 unmodified lines
1138WRAPPER8_16_SQ(rd8x8_c, rd16_c)1021WRAPPER8_16_SQ(rd8x8_c, rd16_c)
1139WRAPPER8_16_SQ(bit8x8_c, bit16_c)1022WRAPPER8_16_SQ(bit8x8_c, bit16_c)
1140 1023
1141static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
1142{
1143 ff_j_rev_dct(block);
1144 put_pixels_clamped_c(block, dest, line_size);
1145}
1146
1147static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
1148{
1149 ff_j_rev_dct(block);
1150 add_pixels_clamped_c(block, dest, line_size);
1151}
1152
1153/* draw the edges of width 'w' of an image of size width, height */1024/* draw the edges of width 'w' of an image of size width, height */
1154// FIXME: Check that this is OK for MPEG-4 interlaced.1025// FIXME: Check that this is OK for MPEG-4 interlaced.
1155static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,1026static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,
@@ -1209,36 +1080,8 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) · 53 unmodified lines
1209 }1080 }
1210#endif /* CONFIG_ENCODERS */1081#endif /* CONFIG_ENCODERS */
1211 1082
1212 if (avctx->bits_per_raw_sample == 10) {
1213 c->idct_put = ff_simple_idct_put_10;
1214 c->idct_add = ff_simple_idct_add_10;
1215 c->idct = ff_simple_idct_10;
1216 c->idct_permutation_type = FF_NO_IDCT_PERM;
1217 } else {
1218 if (avctx->idct_algo == FF_IDCT_INT) {
1219 c->idct_put = jref_idct_put;
1220 c->idct_add = jref_idct_add;
1221 c->idct = ff_j_rev_dct;
1222 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
1223 } else if (avctx->idct_algo == FF_IDCT_FAAN) {
1224 c->idct_put = ff_faanidct_put;
1225 c->idct_add = ff_faanidct_add;
1226 c->idct = ff_faanidct;
1227 c->idct_permutation_type = FF_NO_IDCT_PERM;
1228 } else { // accurate/default
1229 c->idct_put = ff_simple_idct_put_8;
1230 c->idct_add = ff_simple_idct_add_8;
1231 c->idct = ff_simple_idct_8;
1232 c->idct_permutation_type = FF_NO_IDCT_PERM;
1233 }
1234 }
1235
1236 c->diff_pixels = diff_pixels_c;1083 c->diff_pixels = diff_pixels_c;
1237 1084
1238 c->put_pixels_clamped = put_pixels_clamped_c;
1239 c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
1240 c->add_pixels_clamped = add_pixels_clamped_c;
1241
1242 c->sum_abs_dctelem = sum_abs_dctelem_c;1085 c->sum_abs_dctelem = sum_abs_dctelem_c;
1243 1086
1244 c->pix_sum = pix_sum_c;1087 c->pix_sum = pix_sum_c;
@@ -1309,7 +1152,4 @@ av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx) · 64 unmodified lines
1309 ff_dsputil_init_ppc(c, avctx, high_bit_depth);1152 ff_dsputil_init_ppc(c, avctx, high_bit_depth);
1310 if (ARCH_X86)1153 if (ARCH_X86)
1311 ff_dsputil_init_x86(c, avctx, high_bit_depth);1154 ff_dsputil_init_x86(c, avctx, high_bit_depth);
1312
1313 ff_init_scantable_permutation(c->idct_permutation,
1314 c->idct_permutation_type);
1315}1155}
libavcodec/dsputil.h+0−66
@@ -44,22 +44,6 @@ typedef int (*me_cmp_func)(struct MpegEncContext *c, · 43 unmodified lines
44 uint8_t *blk1 /* align width (8 or 16) */,44 uint8_t *blk1 /* align width (8 or 16) */,
45 uint8_t *blk2 /* align 1 */, int line_size, int h);45 uint8_t *blk2 /* align 1 */, int line_size, int h);
46 46
47/**
48 * Scantable.
49 */
50typedef struct ScanTable {
51 const uint8_t *scantable;
52 uint8_t permutated[64];
53 uint8_t raster_end[64];
54} ScanTable;
55
56void ff_init_scantable(uint8_t *permutation, ScanTable *st,
57 const uint8_t *src_scantable);
58void ff_init_scantable_permutation(uint8_t *idct_permutation,
59 int idct_permutation_type);
60int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
61 int idct_permutation_type);
62
63/**47/**
64 * DSPContext.48 * DSPContext.
65 */49 */
@@ -72,15 +56,6 @@ typedef struct DSPContext { · 6 unmodified lines
72 const uint8_t *s1 /* align 8 */,56 const uint8_t *s1 /* align 8 */,
73 const uint8_t *s2 /* align 8 */,57 const uint8_t *s2 /* align 8 */,
74 int stride);58 int stride);
75 void (*put_pixels_clamped)(const int16_t *block /* align 16 */,
76 uint8_t *pixels /* align 8 */,
77 int line_size);
78 void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */,
79 uint8_t *pixels /* align 8 */,
80 int line_size);
81 void (*add_pixels_clamped)(const int16_t *block /* align 16 */,
82 uint8_t *pixels /* align 8 */,
83 int line_size);
84 int (*sum_abs_dctelem)(int16_t *block /* align 16 */);59 int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
85 60
86 int (*pix_sum)(uint8_t *pix, int line_size);61 int (*pix_sum)(uint8_t *pix, int line_size);
@@ -112,47 +87,6 @@ typedef struct DSPContext { · 25 unmodified lines
112 void (*fdct)(int16_t *block /* align 16 */);87 void (*fdct)(int16_t *block /* align 16 */);
113 void (*fdct248)(int16_t *block /* align 16 */);88 void (*fdct248)(int16_t *block /* align 16 */);
114 89
115 /* IDCT really */
116 void (*idct)(int16_t *block /* align 16 */);
117
118 /**
119 * block -> idct -> clip to unsigned 8 bit -> dest.
120 * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
121 * @param line_size size in bytes of a horizontal line of dest
122 */
123 void (*idct_put)(uint8_t *dest /* align 8 */,
124 int line_size, int16_t *block /* align 16 */);
125
126 /**
127 * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
128 * @param line_size size in bytes of a horizontal line of dest
129 */
130 void (*idct_add)(uint8_t *dest /* align 8 */,
131 int line_size, int16_t *block /* align 16 */);
132
133 /**
134 * IDCT input permutation.
135 * Several optimized IDCTs need a permutated input (relative to the
136 * normal order of the reference IDCT).
137 * This permutation must be performed before the idct_put/add.
138 * Note, normally this can be merged with the zigzag/alternate scan<br>
139 * An example to avoid confusion:
140 * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
141 * - (x -> reference DCT -> reference IDCT -> x)
142 * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
143 * -> simple_idct_mmx -> x)
144 * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
145 * -> simple_idct_mmx -> ...)
146 */
147 uint8_t idct_permutation[64];
148 int idct_permutation_type;
149#define FF_NO_IDCT_PERM 1
150#define FF_LIBMPEG2_IDCT_PERM 2
151#define FF_SIMPLE_IDCT_PERM 3
152#define FF_TRANSPOSE_IDCT_PERM 4
153#define FF_PARTTRANS_IDCT_PERM 5
154#define FF_SSE2_IDCT_PERM 6
155
156 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64],90 int (*try_8x8basis)(int16_t rem[64], int16_t weight[64],
157 int16_t basis[64], int scale);91 int16_t basis[64], int scale);
158 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);92 void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
libavcodec/dvdec.c+5−4
@@ -39,6 +39,7 @@ · 38 unmodified lines
39#include "libavutil/imgutils.h"39#include "libavutil/imgutils.h"
40#include "libavutil/pixdesc.h"40#include "libavutil/pixdesc.h"
41#include "avcodec.h"41#include "avcodec.h"
42#include "idctdsp.h"
42#include "internal.h"43#include "internal.h"
43#include "get_bits.h"44#include "get_bits.h"
44#include "put_bits.h"45#include "put_bits.h"
@@ -61,17 +62,17 @@ static const int dv_iweight_bits = 14; · 16 unmodified lines
61static av_cold int dvvideo_decode_init(AVCodecContext *avctx)62static av_cold int dvvideo_decode_init(AVCodecContext *avctx)
62{63{
63 DVVideoContext *s = avctx->priv_data;64 DVVideoContext *s = avctx->priv_data;
64 DSPContext dsp;65 IDCTDSPContext idsp;
65 int i;66 int i;
66 67
67 ff_dsputil_init(&dsp, avctx);68 ff_idctdsp_init(&idsp, avctx);
68 69
69 for (i = 0; i < 64; i++)70 for (i = 0; i < 64; i++)
70 s->dv_zigzag[0][i] = dsp.idct_permutation[ff_zigzag_direct[i]];71 s->dv_zigzag[0][i] = idsp.idct_permutation[ff_zigzag_direct[i]];
71 72
72 memcpy(s->dv_zigzag[1], ff_dv_zigzag248_direct, sizeof(s->dv_zigzag[1]));73 memcpy(s->dv_zigzag[1], ff_dv_zigzag248_direct, sizeof(s->dv_zigzag[1]));
73 74
74 s->idct_put[0] = dsp.idct_put;75 s->idct_put[0] = idsp.idct_put;
75 s->idct_put[1] = ff_simple_idct248_put;76 s->idct_put[1] = ff_simple_idct248_put;
76 77
77 return ff_dvvideo_init(avctx);78 return ff_dvvideo_init(avctx);
libavcodec/dxva2_mpeg2.c+1−1
@@ -110,7 +110,7 @@ static void fill_quantization_matrices(AVCodecContext *avctx, · 109 unmodified lines
110 for (i = 0; i < 4; i++)110 for (i = 0; i < 4; i++)
111 qm->bNewQmatrix[i] = 1;111 qm->bNewQmatrix[i] = 1;
112 for (i = 0; i < 64; i++) {112 for (i = 0; i < 64; i++) {
113 int n = s->dsp.idct_permutation[ff_zigzag_direct[i]];113 int n = s->idsp.idct_permutation[ff_zigzag_direct[i]];
114 qm->Qmatrix[0][i] = s->intra_matrix[n];;114 qm->Qmatrix[0][i] = s->intra_matrix[n];;
115 qm->Qmatrix[1][i] = s->inter_matrix[n];;115 qm->Qmatrix[1][i] = s->inter_matrix[n];;
116 qm->Qmatrix[2][i] = s->chroma_intra_matrix[n];;116 qm->Qmatrix[2][i] = s->chroma_intra_matrix[n];;
libavcodec/eamad.c+5−4
@@ -33,6 +33,7 @@ · 32 unmodified lines
33#include "get_bits.h"33#include "get_bits.h"
34#include "aandcttab.h"34#include "aandcttab.h"
35#include "eaidct.h"35#include "eaidct.h"
36#include "idctdsp.h"
36#include "internal.h"37#include "internal.h"
37#include "mpeg12.h"38#include "mpeg12.h"
38#include "mpeg12data.h"39#include "mpeg12data.h"
@@ -47,7 +48,7 @@ typedef struct MadContext { · 8 unmodified lines
47 AVCodecContext *avctx;48 AVCodecContext *avctx;
48 BlockDSPContext bdsp;49 BlockDSPContext bdsp;
49 BswapDSPContext bbdsp;50 BswapDSPContext bbdsp;
50 DSPContext dsp;51 IDCTDSPContext idsp;
51 AVFrame *last_frame;52 AVFrame *last_frame;
52 GetBitContext gb;53 GetBitContext gb;
53 void *bitstream_buf;54 void *bitstream_buf;
@@ -66,9 +67,9 @@ static av_cold int decode_init(AVCodecContext *avctx) · 12 unmodified lines
66 avctx->pix_fmt = AV_PIX_FMT_YUV420P;67 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
67 ff_blockdsp_init(&s->bdsp, avctx);68 ff_blockdsp_init(&s->bdsp, avctx);
68 ff_bswapdsp_init(&s->bbdsp);69 ff_bswapdsp_init(&s->bbdsp);
69 ff_dsputil_init(&s->dsp, avctx);70 ff_idctdsp_init(&s->idsp, avctx);
70 ff_init_scantable_permutation(s->dsp.idct_permutation, FF_NO_IDCT_PERM);71 ff_init_scantable_permutation(s->idsp.idct_permutation, FF_NO_IDCT_PERM);
71 ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);72 ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_zigzag_direct);
72 ff_mpeg12_init_vlcs();73 ff_mpeg12_init_vlcs();
73 74
74 s->last_frame = av_frame_alloc();75 s->last_frame = av_frame_alloc();
libavcodec/eatgq.c+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
32#define BITSTREAM_READER_LE32#define BITSTREAM_READER_LE
33#include "get_bits.h"33#include "get_bits.h"
34#include "bytestream.h"34#include "bytestream.h"
35#include "dsputil.h"35#include "idctdsp.h"
36#include "aandcttab.h"36#include "aandcttab.h"
37#include "eaidct.h"37#include "eaidct.h"
38#include "internal.h"38#include "internal.h"
libavcodec/eatqi.c+4−3
@@ -32,6 +32,7 @@ · 31 unmodified lines
32#include "get_bits.h"32#include "get_bits.h"
33#include "aandcttab.h"33#include "aandcttab.h"
34#include "eaidct.h"34#include "eaidct.h"
35#include "idctdsp.h"
35#include "internal.h"36#include "internal.h"
36#include "mpeg12.h"37#include "mpeg12.h"
37#include "mpegvideo.h"38#include "mpegvideo.h"
@@ -51,9 +52,9 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx) · 13 unmodified lines
51 s->avctx = avctx;52 s->avctx = avctx;
52 ff_blockdsp_init(&s->bdsp, avctx);53 ff_blockdsp_init(&s->bdsp, avctx);
53 ff_bswapdsp_init(&t->bsdsp);54 ff_bswapdsp_init(&t->bsdsp);
54 ff_dsputil_init(&s->dsp, avctx);55 ff_idctdsp_init(&s->idsp, avctx);
55 ff_init_scantable_permutation(s->dsp.idct_permutation, FF_NO_IDCT_PERM);56 ff_init_scantable_permutation(s->idsp.idct_permutation, FF_NO_IDCT_PERM);
56 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);57 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
57 s->qscale = 1;58 s->qscale = 1;
58 avctx->time_base = (AVRational){1, 15};59 avctx->time_base = (AVRational){1, 15};
59 avctx->pix_fmt = AV_PIX_FMT_YUV420P;60 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
libavcodec/g2meet.c+6−6
@@ -31,7 +31,7 @@ · 30 unmodified lines
31#include "avcodec.h"31#include "avcodec.h"
32#include "blockdsp.h"32#include "blockdsp.h"
33#include "bytestream.h"33#include "bytestream.h"
34#include "dsputil.h"34#include "idctdsp.h"
35#include "get_bits.h"35#include "get_bits.h"
36#include "internal.h"36#include "internal.h"
37#include "mjpeg.h"37#include "mjpeg.h"
@@ -74,7 +74,7 @@ static const uint8_t chroma_quant[64] = { · 36 unmodified lines
74 74
75typedef struct JPGContext {75typedef struct JPGContext {
76 BlockDSPContext bdsp;76 BlockDSPContext bdsp;
77 DSPContext dsp;77 IDCTDSPContext idsp;
78 ScanTable scantable;78 ScanTable scantable;
79 79
80 VLC dc_vlc[2], ac_vlc[2];80 VLC dc_vlc[2], ac_vlc[2];
@@ -153,8 +153,8 @@ static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c) · 72 unmodified lines
153 return ret;153 return ret;
154 154
155 ff_blockdsp_init(&c->bdsp, avctx);155 ff_blockdsp_init(&c->bdsp, avctx);
156 ff_dsputil_init(&c->dsp, avctx);156 ff_idctdsp_init(&c->idsp, avctx);
157 ff_init_scantable(c->dsp.idct_permutation, &c->scantable,157 ff_init_scantable(c->idsp.idct_permutation, &c->scantable,
158 ff_zigzag_direct);158 ff_zigzag_direct);
159 159
160 return 0;160 return 0;
@@ -279,13 +279,13 @@ static int jpg_decode_data(JPGContext *c, int width, int height, · 118 unmodified lines
279 if ((ret = jpg_decode_block(c, &gb, 0,279 if ((ret = jpg_decode_block(c, &gb, 0,
280 c->block[i + j * 2])) != 0)280 c->block[i + j * 2])) != 0)
281 return ret;281 return ret;
282 c->dsp.idct(c->block[i + j * 2]);282 c->idsp.idct(c->block[i + j * 2]);
283 }283 }
284 }284 }
285 for (i = 1; i < 3; i++) {285 for (i = 1; i < 3; i++) {
286 if ((ret = jpg_decode_block(c, &gb, i, c->block[i + 3])) != 0)286 if ((ret = jpg_decode_block(c, &gb, i, c->block[i + 3])) != 0)
287 return ret;287 return ret;
288 c->dsp.idct(c->block[i + 3]);288 c->idsp.idct(c->block[i + 3]);
289 }289 }
290 290
291 for (j = 0; j < 16; j++) {291 for (j = 0; j < 16; j++) {
libavcodec/h263.c+4−4
@@ -267,7 +267,7 @@ void ff_h263_pred_acdc(MpegEncContext * s, int16_t *block, int n) · 266 unmodified lines
267 if (a != 1024) {267 if (a != 1024) {
268 ac_val -= 16;268 ac_val -= 16;
269 for(i=1;i<8;i++) {269 for(i=1;i<8;i++) {
270 block[s->dsp.idct_permutation[i<<3]] += ac_val[i];270 block[s->idsp.idct_permutation[i << 3]] += ac_val[i];
271 }271 }
272 pred_dc = a;272 pred_dc = a;
273 }273 }
@@ -276,7 +276,7 @@ void ff_h263_pred_acdc(MpegEncContext * s, int16_t *block, int n) · 2 unmodified lines
276 if (c != 1024) {276 if (c != 1024) {
277 ac_val -= 16 * wrap;277 ac_val -= 16 * wrap;
278 for(i=1;i<8;i++) {278 for(i=1;i<8;i++) {
279 block[s->dsp.idct_permutation[i ]] += ac_val[i + 8];279 block[s->idsp.idct_permutation[i]] += ac_val[i + 8];
280 }280 }
281 pred_dc = c;281 pred_dc = c;
282 }282 }
@@ -304,10 +304,10 @@ void ff_h263_pred_acdc(MpegEncContext * s, int16_t *block, int n) · 21 unmodified lines
304 304
305 /* left copy */305 /* left copy */
306 for(i=1;i<8;i++)306 for(i=1;i<8;i++)
307 ac_val1[i ] = block[s->dsp.idct_permutation[i<<3]];307 ac_val1[i] = block[s->idsp.idct_permutation[i << 3]];
308 /* top copy */308 /* top copy */
309 for(i=1;i<8;i++)309 for(i=1;i<8;i++)
310 ac_val1[8 + i] = block[s->dsp.idct_permutation[i ]];310 ac_val1[8 + i] = block[s->idsp.idct_permutation[i]];
311}311}
312 312
313int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,313int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,
libavcodec/idctdsp.c+197−0
@@ -0,0 +1,197 @@
1/*
2 * This file is part of Libav.
3 *
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20#include "libavutil/attributes.h"
21#include "libavutil/common.h"
22#include "avcodec.h"
23#include "dct.h"
24#include "faanidct.h"
25#include "idctdsp.h"
26#include "simple_idct.h"
27
28av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
29 const uint8_t *src_scantable)
30{
31 int i, end;
32
33 st->scantable = src_scantable;
34
35 for (i = 0; i < 64; i++) {
36 int j = src_scantable[i];
37 st->permutated[i] = permutation[j];
38 }
39
40 end = -1;
41 for (i = 0; i < 64; i++) {
42 int j = st->permutated[i];
43 if (j > end)
44 end = j;
45 st->raster_end[i] = end;
46 }
47}
48
49av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
50 int idct_permutation_type)
51{
52 int i;
53
54 if (ARCH_X86)
55 if (ff_init_scantable_permutation_x86(idct_permutation,
56 idct_permutation_type))
57 return;
58
59 switch (idct_permutation_type) {
60 case FF_NO_IDCT_PERM:
61 for (i = 0; i < 64; i++)
62 idct_permutation[i] = i;
63 break;
64 case FF_LIBMPEG2_IDCT_PERM:
65 for (i = 0; i < 64; i++)
66 idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
67 break;
68 case FF_TRANSPOSE_IDCT_PERM:
69 for (i = 0; i < 64; i++)
70 idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
71 break;
72 case FF_PARTTRANS_IDCT_PERM:
73 for (i = 0; i < 64; i++)
74 idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
75 break;
76 default:
77 av_log(NULL, AV_LOG_ERROR,
78 "Internal error, IDCT permutation not set\n");
79 }
80}
81
82static void put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
83 int line_size)
84{
85 int i;
86
87 /* read the pixels */
88 for (i = 0; i < 8; i++) {
89 pixels[0] = av_clip_uint8(block[0]);
90 pixels[1] = av_clip_uint8(block[1]);
91 pixels[2] = av_clip_uint8(block[2]);
92 pixels[3] = av_clip_uint8(block[3]);
93 pixels[4] = av_clip_uint8(block[4]);
94 pixels[5] = av_clip_uint8(block[5]);
95 pixels[6] = av_clip_uint8(block[6]);
96 pixels[7] = av_clip_uint8(block[7]);
97
98 pixels += line_size;
99 block += 8;
100 }
101}
102
103static void put_signed_pixels_clamped_c(const int16_t *block,
104 uint8_t *restrict pixels,
105 int line_size)
106{
107 int i, j;
108
109 for (i = 0; i < 8; i++) {
110 for (j = 0; j < 8; j++) {
111 if (*block < -128)
112 *pixels = 0;
113 else if (*block > 127)
114 *pixels = 255;
115 else
116 *pixels = (uint8_t) (*block + 128);
117 block++;
118 pixels++;
119 }
120 pixels += (line_size - 8);
121 }
122}
123
124static void add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
125 int line_size)
126{
127 int i;
128
129 /* read the pixels */
130 for (i = 0; i < 8; i++) {
131 pixels[0] = av_clip_uint8(pixels[0] + block[0]);
132 pixels[1] = av_clip_uint8(pixels[1] + block[1]);
133 pixels[2] = av_clip_uint8(pixels[2] + block[2]);
134 pixels[3] = av_clip_uint8(pixels[3] + block[3]);
135 pixels[4] = av_clip_uint8(pixels[4] + block[4]);
136 pixels[5] = av_clip_uint8(pixels[5] + block[5]);
137 pixels[6] = av_clip_uint8(pixels[6] + block[6]);
138 pixels[7] = av_clip_uint8(pixels[7] + block[7]);
139 pixels += line_size;
140 block += 8;
141 }
142}
143
144static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
145{
146 ff_j_rev_dct(block);
147 put_pixels_clamped_c(block, dest, line_size);
148}
149
150static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
151{
152 ff_j_rev_dct(block);
153 add_pixels_clamped_c(block, dest, line_size);
154}
155
156av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
157{
158 const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
159
160 if (avctx->bits_per_raw_sample == 10) {
161 c->idct_put = ff_simple_idct_put_10;
162 c->idct_add = ff_simple_idct_add_10;
163 c->idct = ff_simple_idct_10;
164 c->idct_permutation_type = FF_NO_IDCT_PERM;
165 } else {
166 if (avctx->idct_algo == FF_IDCT_INT) {
167 c->idct_put = jref_idct_put;
168 c->idct_add = jref_idct_add;
169 c->idct = ff_j_rev_dct;
170 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
171 } else if (avctx->idct_algo == FF_IDCT_FAAN) {
172 c->idct_put = ff_faanidct_put;
173 c->idct_add = ff_faanidct_add;
174 c->idct = ff_faanidct;
175 c->idct_permutation_type = FF_NO_IDCT_PERM;
176 } else { // accurate/default
177 c->idct_put = ff_simple_idct_put_8;
178 c->idct_add = ff_simple_idct_add_8;
179 c->idct = ff_simple_idct_8;
180 c->idct_permutation_type = FF_NO_IDCT_PERM;
181 }
182 }
183
184 c->put_pixels_clamped = put_pixels_clamped_c;
185 c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
186 c->add_pixels_clamped = add_pixels_clamped_c;
187
188 if (ARCH_ARM)
189 ff_idctdsp_init_arm(c, avctx, high_bit_depth);
190 if (ARCH_PPC)
191 ff_idctdsp_init_ppc(c, avctx, high_bit_depth);
192 if (ARCH_X86)
193 ff_idctdsp_init_x86(c, avctx, high_bit_depth);
194
195 ff_init_scantable_permutation(c->idct_permutation,
196 c->idct_permutation_type);
197}
libavcodec/idctdsp.h+104−0
@@ -0,0 +1,104 @@
1/*
2 * This file is part of Libav.
3 *
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_IDCTDSP_H
20#define AVCODEC_IDCTDSP_H
21
22#include <stdint.h>
23
24#include "avcodec.h"
25
26/**
27 * Scantable.
28 */
29typedef struct ScanTable {
30 const uint8_t *scantable;
31 uint8_t permutated[64];
32 uint8_t raster_end[64];
33} ScanTable;
34
35void ff_init_scantable(uint8_t *permutation, ScanTable *st,
36 const uint8_t *src_scantable);
37void ff_init_scantable_permutation(uint8_t *idct_permutation,
38 int idct_permutation_type);
39int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
40 int idct_permutation_type);
41
42typedef struct IDCTDSPContext {
43 /* pixel ops : interface with DCT */
44 void (*put_pixels_clamped)(const int16_t *block /* align 16 */,
45 uint8_t *pixels /* align 8 */,
46 int line_size);
47 void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */,
48 uint8_t *pixels /* align 8 */,
49 int line_size);
50 void (*add_pixels_clamped)(const int16_t *block /* align 16 */,
51 uint8_t *pixels /* align 8 */,
52 int line_size);
53
54 void (*idct)(int16_t *block /* align 16 */);
55
56 /**
57 * block -> idct -> clip to unsigned 8 bit -> dest.
58 * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
59 * @param line_size size in bytes of a horizontal line of dest
60 */
61 void (*idct_put)(uint8_t *dest /* align 8 */,
62 int line_size, int16_t *block /* align 16 */);
63
64 /**
65 * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
66 * @param line_size size in bytes of a horizontal line of dest
67 */
68 void (*idct_add)(uint8_t *dest /* align 8 */,
69 int line_size, int16_t *block /* align 16 */);
70
71 /**
72 * IDCT input permutation.
73 * Several optimized IDCTs need a permutated input (relative to the
74 * normal order of the reference IDCT).
75 * This permutation must be performed before the idct_put/add.
76 * Note, normally this can be merged with the zigzag/alternate scan<br>
77 * An example to avoid confusion:
78 * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
79 * - (x -> reference DCT -> reference IDCT -> x)
80 * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
81 * -> simple_idct_mmx -> x)
82 * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
83 * -> simple_idct_mmx -> ...)
84 */
85 uint8_t idct_permutation[64];
86 int idct_permutation_type;
87#define FF_NO_IDCT_PERM 1
88#define FF_LIBMPEG2_IDCT_PERM 2
89#define FF_SIMPLE_IDCT_PERM 3
90#define FF_TRANSPOSE_IDCT_PERM 4
91#define FF_PARTTRANS_IDCT_PERM 5
92#define FF_SSE2_IDCT_PERM 6
93} IDCTDSPContext;
94
95void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx);
96
97void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx,
98 unsigned high_bit_depth);
99void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx,
100 unsigned high_bit_depth);
101void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
102 unsigned high_bit_depth);
103
104#endif /* AVCODEC_IDCTDSP_H */
libavcodec/intrax8.c+8−7
@@ -24,6 +24,7 @@ · 23 unmodified lines
24#include "avcodec.h"24#include "avcodec.h"
25#include "error_resilience.h"25#include "error_resilience.h"
26#include "get_bits.h"26#include "get_bits.h"
27#include "idctdsp.h"
27#include "mpegvideo.h"28#include "mpegvideo.h"
28#include "msmpeg4data.h"29#include "msmpeg4data.h"
29#include "intrax8huf.h"30#include "intrax8huf.h"
@@ -440,7 +441,7 @@ lut2[q>12][c]={ · 410 unmodified lines
440static void x8_ac_compensation(IntraX8Context * const w, int const direction, int const dc_level){441static void x8_ac_compensation(IntraX8Context * const w, int const direction, int const dc_level){
441 MpegEncContext * const s= w->s;442 MpegEncContext * const s= w->s;
442 int t;443 int t;
443#define B(x,y) s->block[0][s->dsp.idct_permutation[(x)+(y)*8]]444#define B(x, y) s->block[0][s->idsp.idct_permutation[(x) + (y) * 8]]
444#define T(x) ((x) * dc_level + 0x8000) >> 16;445#define T(x) ((x) * dc_level + 0x8000) >> 16;
445 switch(direction){446 switch(direction){
446 case 0:447 case 0:
@@ -646,9 +647,9 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){ · 199 unmodified lines
646 s->current_picture.f->linesize[!!chroma] );647 s->current_picture.f->linesize[!!chroma] );
647 }648 }
648 if(!zeros_only)649 if(!zeros_only)
649 s->dsp.idct_add ( s->dest[chroma],650 s->idsp.idct_add(s->dest[chroma],
650 s->current_picture.f->linesize[!!chroma],651 s->current_picture.f->linesize[!!chroma],
651 s->block[0] );652 s->block[0]);
652 653
653block_placed:654block_placed:
654 655
@@ -698,9 +699,9 @@ av_cold void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s · 43 unmodified lines
698 assert(s->mb_width>0);699 assert(s->mb_width>0);
699 w->prediction_table=av_mallocz(s->mb_width*2*2);//two rows, 2 blocks per cannon mb700 w->prediction_table=av_mallocz(s->mb_width*2*2);//two rows, 2 blocks per cannon mb
700 701
701 ff_init_scantable(s->dsp.idct_permutation, &w->scantable[0], ff_wmv1_scantable[0]);702 ff_init_scantable(s->idsp.idct_permutation, &w->scantable[0], ff_wmv1_scantable[0]);
702 ff_init_scantable(s->dsp.idct_permutation, &w->scantable[1], ff_wmv1_scantable[2]);703 ff_init_scantable(s->idsp.idct_permutation, &w->scantable[1], ff_wmv1_scantable[2]);
703 ff_init_scantable(s->dsp.idct_permutation, &w->scantable[2], ff_wmv1_scantable[3]);704 ff_init_scantable(s->idsp.idct_permutation, &w->scantable[2], ff_wmv1_scantable[3]);
704 705
705 ff_intrax8dsp_init(&w->dsp);706 ff_intrax8dsp_init(&w->dsp);
706}707}
libavcodec/ljpegenc.c+5−4
@@ -35,7 +35,7 @@ · 34 unmodified lines
35#include "libavutil/pixdesc.h"35#include "libavutil/pixdesc.h"
36 36
37#include "avcodec.h"37#include "avcodec.h"
38#include "dsputil.h"38#include "idctdsp.h"
39#include "internal.h"39#include "internal.h"
40#include "mjpegenc_common.h"40#include "mjpegenc_common.h"
41#include "mpegvideo.h"41#include "mpegvideo.h"
@@ -43,7 +43,7 @@ · 1 unmodified line
43#include "mjpegenc.h"43#include "mjpegenc.h"
44 44
45typedef struct LJpegEncContext {45typedef struct LJpegEncContext {
46 DSPContext dsp;46 IDCTDSPContext idsp;
47 ScanTable scantable;47 ScanTable scantable;
48 uint16_t matrix[64];48 uint16_t matrix[64];
49 49
@@ -285,8 +285,9 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx) · 235 unmodified lines
285 285
286 s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));286 s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
287 287
288 ff_dsputil_init(&s->dsp, avctx);288 ff_idctdsp_init(&s->idsp, avctx);
289 ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);289 ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
290 ff_zigzag_direct);
290 291
291 av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,292 av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
292 &chroma_v_shift);293 &chroma_v_shift);
libavcodec/mdec.c+11−9
@@ -29,6 +29,7 @@ · 28 unmodified lines
29 29
30#include "avcodec.h"30#include "avcodec.h"
31#include "blockdsp.h"31#include "blockdsp.h"
32#include "idctdsp.h"
32#include "mpegvideo.h"33#include "mpegvideo.h"
33#include "mpeg12.h"34#include "mpeg12.h"
34#include "thread.h"35#include "thread.h"
@@ -36,7 +37,7 @@ · 1 unmodified line
36typedef struct MDECContext {37typedef struct MDECContext {
37 AVCodecContext *avctx;38 AVCodecContext *avctx;
38 BlockDSPContext bdsp;39 BlockDSPContext bdsp;
39 DSPContext dsp;40 IDCTDSPContext idsp;
40 ThreadFrame frame;41 ThreadFrame frame;
41 GetBitContext gb;42 GetBitContext gb;
42 ScanTable scantable;43 ScanTable scantable;
@@ -146,14 +147,14 @@ static inline void idct_put(MDECContext *a, AVFrame *frame, int mb_x, int mb_y) · 103 unmodified lines
146 uint8_t *dest_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8;147 uint8_t *dest_cb = frame->data[1] + (mb_y * 8 * frame->linesize[1]) + mb_x * 8;
147 uint8_t *dest_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8;148 uint8_t *dest_cr = frame->data[2] + (mb_y * 8 * frame->linesize[2]) + mb_x * 8;
148 149
149 a->dsp.idct_put(dest_y, linesize, block[0]);150 a->idsp.idct_put(dest_y, linesize, block[0]);
150 a->dsp.idct_put(dest_y + 8, linesize, block[1]);151 a->idsp.idct_put(dest_y + 8, linesize, block[1]);
151 a->dsp.idct_put(dest_y + 8 * linesize, linesize, block[2]);152 a->idsp.idct_put(dest_y + 8 * linesize, linesize, block[2]);
152 a->dsp.idct_put(dest_y + 8 * linesize + 8, linesize, block[3]);153 a->idsp.idct_put(dest_y + 8 * linesize + 8, linesize, block[3]);
153 154
154 if (!(a->avctx->flags & CODEC_FLAG_GRAY)) {155 if (!(a->avctx->flags & CODEC_FLAG_GRAY)) {
155 a->dsp.idct_put(dest_cb, frame->linesize[1], block[4]);156 a->idsp.idct_put(dest_cb, frame->linesize[1], block[4]);
156 a->dsp.idct_put(dest_cr, frame->linesize[2], block[5]);157 a->idsp.idct_put(dest_cr, frame->linesize[2], block[5]);
157 }158 }
158}159}
159 160
@@ -215,9 +216,10 @@ static av_cold int decode_init(AVCodecContext *avctx) · 55 unmodified lines
215 a->avctx = avctx;216 a->avctx = avctx;
216 217
217 ff_blockdsp_init(&a->bdsp, avctx);218 ff_blockdsp_init(&a->bdsp, avctx);
218 ff_dsputil_init(&a->dsp, avctx);219 ff_idctdsp_init(&a->idsp, avctx);
219 ff_mpeg12_init_vlcs();220 ff_mpeg12_init_vlcs();
220 ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_zigzag_direct);221 ff_init_scantable(a->idsp.idct_permutation, &a->scantable,
222 ff_zigzag_direct);
221 223
222 if (avctx->idct_algo == FF_IDCT_AUTO)224 if (avctx->idct_algo == FF_IDCT_AUTO)
223 avctx->idct_algo = FF_IDCT_SIMPLE;225 avctx->idct_algo = FF_IDCT_SIMPLE;
libavcodec/mimic.c+5−5
@@ -29,8 +29,8 @@ · 28 unmodified lines
29#include "get_bits.h"29#include "get_bits.h"
30#include "bytestream.h"30#include "bytestream.h"
31#include "bswapdsp.h"31#include "bswapdsp.h"
32#include "dsputil.h"
33#include "hpeldsp.h"32#include "hpeldsp.h"
33#include "idctdsp.h"
34#include "thread.h"34#include "thread.h"
35 35
36#define MIMIC_HEADER_SIZE 2036#define MIMIC_HEADER_SIZE 20
@@ -56,8 +56,8 @@ typedef struct { · 19 unmodified lines
56 ScanTable scantable;56 ScanTable scantable;
57 BlockDSPContext bdsp;57 BlockDSPContext bdsp;
58 BswapDSPContext bbdsp;58 BswapDSPContext bbdsp;
59 DSPContext dsp;
60 HpelDSPContext hdsp;59 HpelDSPContext hdsp;
60 IDCTDSPContext idsp;
61 VLC vlc;61 VLC vlc;
62 62
63 /* Kept in the context so multithreading can have a constant to read from */63 /* Kept in the context so multithreading can have a constant to read from */
@@ -151,9 +151,9 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx) · 87 unmodified lines
151 }151 }
152 ff_blockdsp_init(&ctx->bdsp, avctx);152 ff_blockdsp_init(&ctx->bdsp, avctx);
153 ff_bswapdsp_init(&ctx->bbdsp);153 ff_bswapdsp_init(&ctx->bbdsp);
154 ff_dsputil_init(&ctx->dsp, avctx);
155 ff_hpeldsp_init(&ctx->hdsp, avctx->flags);154 ff_hpeldsp_init(&ctx->hdsp, avctx->flags);
156 ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, col_zag);155 ff_idctdsp_init(&ctx->idsp, avctx);
156 ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, col_zag);
157 157
158 for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {158 for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {
159 ctx->frames[i].f = av_frame_alloc();159 ctx->frames[i].f = av_frame_alloc();
@@ -302,7 +302,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs, · 142 unmodified lines
302 "block.\n");302 "block.\n");
303 return ret;303 return ret;
304 }304 }
305 ctx->dsp.idct_put(dst, stride, ctx->dct_block);305 ctx->idsp.idct_put(dst, stride, ctx->dct_block);
306 } else {306 } else {
307 unsigned int backref = get_bits(&ctx->gb, 4);307 unsigned int backref = get_bits(&ctx->gb, 4);
308 int index = (ctx->cur_index + backref) & 15;308 int index = (ctx->cur_index + backref) & 15;
libavcodec/mjpegdec.c+6−4
@@ -36,6 +36,7 @@ · 35 unmodified lines
36#include "libavutil/opt.h"36#include "libavutil/opt.h"
37#include "avcodec.h"37#include "avcodec.h"
38#include "blockdsp.h"38#include "blockdsp.h"
39#include "idctdsp.h"
39#include "internal.h"40#include "internal.h"
40#include "mjpeg.h"41#include "mjpeg.h"
41#include "mjpegdec.h"42#include "mjpegdec.h"
@@ -95,8 +96,9 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) · 53 unmodified lines
95 s->avctx = avctx;96 s->avctx = avctx;
96 ff_blockdsp_init(&s->bdsp, avctx);97 ff_blockdsp_init(&s->bdsp, avctx);
97 ff_hpeldsp_init(&s->hdsp, avctx->flags);98 ff_hpeldsp_init(&s->hdsp, avctx->flags);
98 ff_dsputil_init(&s->dsp, avctx);99 ff_idctdsp_init(&s->idsp, avctx);
99 ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);100 ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
101 ff_zigzag_direct);
100 s->buffer_size = 0;102 s->buffer_size = 0;
101 s->buffer = NULL;103 s->buffer = NULL;
102 s->start_code = -1;104 s->start_code = -1;
@@ -889,7 +891,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, · 786 unmodified lines
889 "error y=%d x=%d\n", mb_y, mb_x);891 "error y=%d x=%d\n", mb_y, mb_x);
890 return AVERROR_INVALIDDATA;892 return AVERROR_INVALIDDATA;
891 }893 }
892 s->dsp.idct_put(ptr, linesize[c], s->block);894 s->idsp.idct_put(ptr, linesize[c], s->block);
893 }895 }
894 } else {896 } else {
895 int block_idx = s->block_stride[c] * (v * mb_y + y) +897 int block_idx = s->block_stride[c] * (v * mb_y + y) +
@@ -1002,7 +1004,7 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, · 106 unmodified lines
1002 reference_data + block_offset,1004 reference_data + block_offset,
1003 linesize, 8);1005 linesize, 8);
1004 } else {1006 } else {
1005 s->dsp.idct_put(ptr, linesize, *block);1007 s->idsp.idct_put(ptr, linesize, *block);
1006 ptr += 8;1008 ptr += 8;
1007 }1009 }
1008 }1010 }
libavcodec/mjpegdec.h+2−2
@@ -35,8 +35,8 @@ · 34 unmodified lines
35#include "avcodec.h"35#include "avcodec.h"
36#include "blockdsp.h"36#include "blockdsp.h"
37#include "get_bits.h"37#include "get_bits.h"
38#include "dsputil.h"
39#include "hpeldsp.h"38#include "hpeldsp.h"
39#include "idctdsp.h"
40 40
41#define MAX_COMPONENTS 441#define MAX_COMPONENTS 4
42 42
@@ -97,8 +97,8 @@ typedef struct MJpegDecodeContext { · 54 unmodified lines
97 uint64_t coefs_finished[MAX_COMPONENTS]; ///< bitmask of which coefs have been completely decoded (progressive mode)97 uint64_t coefs_finished[MAX_COMPONENTS]; ///< bitmask of which coefs have been completely decoded (progressive mode)
98 ScanTable scantable;98 ScanTable scantable;
99 BlockDSPContext bdsp;99 BlockDSPContext bdsp;
100 DSPContext dsp;
101 HpelDSPContext hdsp;100 HpelDSPContext hdsp;
101 IDCTDSPContext idsp;
102 102
103 int restart_interval;103 int restart_interval;
104 int restart_count;104 int restart_count;
libavcodec/mjpegenc_common.c+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
26#include "libavutil/pixfmt.h"26#include "libavutil/pixfmt.h"
27 27
28#include "avcodec.h"28#include "avcodec.h"
29#include "dsputil.h"29#include "idctdsp.h"
30#include "put_bits.h"30#include "put_bits.h"
31#include "mjpegenc_common.h"31#include "mjpegenc_common.h"
32#include "mjpeg.h"32#include "mjpeg.h"
libavcodec/mjpegenc_common.h+1−1
@@ -24,7 +24,7 @@ · 23 unmodified lines
24#include <stdint.h>24#include <stdint.h>
25 25
26#include "avcodec.h"26#include "avcodec.h"
27#include "dsputil.h"27#include "idctdsp.h"
28#include "put_bits.h"28#include "put_bits.h"
29 29
30void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,30void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
libavcodec/mpeg12dec.c+15−15
@@ -33,8 +33,8 @@ · 32 unmodified lines
33 33
34#include "avcodec.h"34#include "avcodec.h"
35#include "bytestream.h"35#include "bytestream.h"
36#include "dsputil.h"
37#include "error_resilience.h"36#include "error_resilience.h"
37#include "idctdsp.h"
38#include "internal.h"38#include "internal.h"
39#include "mpeg_er.h"39#include "mpeg_er.h"
40#include "mpeg12.h"40#include "mpeg12.h"
@@ -1100,7 +1100,7 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx) · 1059 unmodified lines
1100 /* we need some permutation to store matrices,1100 /* we need some permutation to store matrices,
1101 * until MPV_common_init() sets the real permutation. */1101 * until MPV_common_init() sets the real permutation. */
1102 for (i = 0; i < 64; i++)1102 for (i = 0; i < 64; i++)
1103 s2->dsp.idct_permutation[i] = i;1103 s2->idsp.idct_permutation[i] = i;
1104 1104
1105 ff_MPV_decode_defaults(s2);1105 ff_MPV_decode_defaults(s2);
1106 1106
@@ -1309,15 +1309,15 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) · 202 unmodified lines
1309 1309
1310 /* Quantization matrices may need reordering1310 /* Quantization matrices may need reordering
1311 * if DCT permutation is changed. */1311 * if DCT permutation is changed. */
1312 memcpy(old_permutation, s->dsp.idct_permutation, 64 * sizeof(uint8_t));1312 memcpy(old_permutation, s->idsp.idct_permutation, 64 * sizeof(uint8_t));
1313 1313
1314 if (ff_MPV_common_init(s) < 0)1314 if (ff_MPV_common_init(s) < 0)
1315 return -2;1315 return -2;
1316 1316
1317 quant_matrix_rebuild(s->intra_matrix, old_permutation, s->dsp.idct_permutation);1317 quant_matrix_rebuild(s->intra_matrix, old_permutation, s->idsp.idct_permutation);
1318 quant_matrix_rebuild(s->inter_matrix, old_permutation, s->dsp.idct_permutation);1318 quant_matrix_rebuild(s->inter_matrix, old_permutation, s->idsp.idct_permutation);
1319 quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->dsp.idct_permutation);1319 quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->idsp.idct_permutation);
1320 quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->dsp.idct_permutation);1320 quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->idsp.idct_permutation);
1321 1321
1322 s1->mpeg_enc_ctx_allocated = 1;1322 s1->mpeg_enc_ctx_allocated = 1;
1323 }1323 }
@@ -1469,7 +1469,7 @@ static int load_matrix(MpegEncContext *s, uint16_t matrix0[64], · 145 unmodified lines
1469 int i;1469 int i;
1470 1470
1471 for (i = 0; i < 64; i++) {1471 for (i = 0; i < 64; i++) {
1472 int j = s->dsp.idct_permutation[ff_zigzag_direct[i]];1472 int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
1473 int v = get_bits(&s->gb, 8);1473 int v = get_bits(&s->gb, 8);
1474 if (v == 0) {1474 if (v == 0) {
1475 av_log(s->avctx, AV_LOG_ERROR, "matrix damaged\n");1475 av_log(s->avctx, AV_LOG_ERROR, "matrix damaged\n");
@@ -1561,11 +1561,11 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) · 85 unmodified lines
1561 }1561 }
1562 1562
1563 if (s->alternate_scan) {1563 if (s->alternate_scan) {
1564 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan);1564 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan);
1565 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan);1565 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan);
1566 } else {1566 } else {
1567 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);1567 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);
1568 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);1568 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
1569 }1569 }
1570 1570
1571 /* composite display not parsed */1571 /* composite display not parsed */
@@ -2070,7 +2070,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, · 498 unmodified lines
2070 load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);2070 load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
2071 } else {2071 } else {
2072 for (i = 0; i < 64; i++) {2072 for (i = 0; i < 64; i++) {
2073 j = s->dsp.idct_permutation[i];2073 j = s->idsp.idct_permutation[i];
2074 v = ff_mpeg1_default_intra_matrix[i];2074 v = ff_mpeg1_default_intra_matrix[i];
2075 s->intra_matrix[j] = v;2075 s->intra_matrix[j] = v;
2076 s->chroma_intra_matrix[j] = v;2076 s->chroma_intra_matrix[j] = v;
@@ -2080,7 +2080,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, · 3 unmodified lines
2080 load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);2080 load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
2081 } else {2081 } else {
2082 for (i = 0; i < 64; i++) {2082 for (i = 0; i < 64; i++) {
2083 int j = s->dsp.idct_permutation[i];2083 int j = s->idsp.idct_permutation[i];
2084 v = ff_mpeg1_default_non_intra_matrix[i];2084 v = ff_mpeg1_default_non_intra_matrix[i];
2085 s->inter_matrix[j] = v;2085 s->inter_matrix[j] = v;
2086 s->chroma_inter_matrix[j] = v;2086 s->chroma_inter_matrix[j] = v;
@@ -2142,7 +2142,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx) · 55 unmodified lines
2142 s1->mpeg_enc_ctx_allocated = 1;2142 s1->mpeg_enc_ctx_allocated = 1;
2143 2143
2144 for (i = 0; i < 64; i++) {2144 for (i = 0; i < 64; i++) {
2145 int j = s->dsp.idct_permutation[i];2145 int j = s->idsp.idct_permutation[i];
2146 v = ff_mpeg1_default_intra_matrix[i];2146 v = ff_mpeg1_default_intra_matrix[i];
2147 s->intra_matrix[j] = v;2147 s->intra_matrix[j] = v;
2148 s->chroma_intra_matrix[j] = v;2148 s->chroma_intra_matrix[j] = v;
libavcodec/mpeg4videodec.c+20−19
@@ -21,6 +21,7 @@ · 20 unmodified lines
21 */21 */
22 22
23#include "error_resilience.h"23#include "error_resilience.h"
24#include "idctdsp.h"
24#include "internal.h"25#include "internal.h"
25#include "mpegutils.h"26#include "mpegutils.h"
26#include "mpegvideo.h"27#include "mpegvideo.h"
@@ -71,11 +72,11 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir) · 44 unmodified lines
71 n == 1 || n == 3) {72 n == 1 || n == 3) {
72 /* same qscale */73 /* same qscale */
73 for (i = 1; i < 8; i++)74 for (i = 1; i < 8; i++)
74 block[s->dsp.idct_permutation[i << 3]] += ac_val[i];75 block[s->idsp.idct_permutation[i << 3]] += ac_val[i];
75 } else {76 } else {
76 /* different qscale, we must rescale */77 /* different qscale, we must rescale */
77 for (i = 1; i < 8; i++)78 for (i = 1; i < 8; i++)
78 block[s->dsp.idct_permutation[i << 3]] += ROUNDED_DIV(ac_val[i] * qscale_table[xy], s->qscale);79 block[s->idsp.idct_permutation[i << 3]] += ROUNDED_DIV(ac_val[i] * qscale_table[xy], s->qscale);
79 }80 }
80 } else {81 } else {
81 const int xy = s->mb_x + s->mb_y * s->mb_stride - s->mb_stride;82 const int xy = s->mb_x + s->mb_y * s->mb_stride - s->mb_stride;
@@ -86,21 +87,21 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir) · 4 unmodified lines
86 n == 2 || n == 3) {87 n == 2 || n == 3) {
87 /* same qscale */88 /* same qscale */
88 for (i = 1; i < 8; i++)89 for (i = 1; i < 8; i++)
89 block[s->dsp.idct_permutation[i]] += ac_val[i + 8];90 block[s->idsp.idct_permutation[i]] += ac_val[i + 8];
90 } else {91 } else {
91 /* different qscale, we must rescale */92 /* different qscale, we must rescale */
92 for (i = 1; i < 8; i++)93 for (i = 1; i < 8; i++)
93 block[s->dsp.idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8] * qscale_table[xy], s->qscale);94 block[s->idsp.idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8] * qscale_table[xy], s->qscale);
94 }95 }
95 }96 }
96 }97 }
97 /* left copy */98 /* left copy */
98 for (i = 1; i < 8; i++)99 for (i = 1; i < 8; i++)
99 ac_val1[i] = block[s->dsp.idct_permutation[i << 3]];100 ac_val1[i] = block[s->idsp.idct_permutation[i << 3]];
100 101
101 /* top copy */102 /* top copy */
102 for (i = 1; i < 8; i++)103 for (i = 1; i < 8; i++)
103 ac_val1[8 + i] = block[s->dsp.idct_permutation[i]];104 ac_val1[8 + i] = block[s->idsp.idct_permutation[i]];
104}105}
105 106
106/**107/**
@@ -1815,7 +1816,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 1708 unmodified lines
1815 1816
1816 /* load default matrixes */1817 /* load default matrixes */
1817 for (i = 0; i < 64; i++) {1818 for (i = 0; i < 64; i++) {
1818 int j = s->dsp.idct_permutation[i];1819 int j = s->idsp.idct_permutation[i];
1819 v = ff_mpeg4_default_intra_matrix[i];1820 v = ff_mpeg4_default_intra_matrix[i];
1820 s->intra_matrix[j] = v;1821 s->intra_matrix[j] = v;
1821 s->chroma_intra_matrix[j] = v;1822 s->chroma_intra_matrix[j] = v;
@@ -1835,14 +1836,14 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 13 unmodified lines
1835 break;1836 break;
1836 1837
1837 last = v;1838 last = v;
1838 j = s->dsp.idct_permutation[ff_zigzag_direct[i]];1839 j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
1839 s->intra_matrix[j] = last;1840 s->intra_matrix[j] = last;
1840 s->chroma_intra_matrix[j] = last;1841 s->chroma_intra_matrix[j] = last;
1841 }1842 }
1842 1843
1843 /* replicate last value */1844 /* replicate last value */
1844 for (; i < 64; i++) {1845 for (; i < 64; i++) {
1845 int j = s->dsp.idct_permutation[ff_zigzag_direct[i]];1846 int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
1846 s->intra_matrix[j] = last;1847 s->intra_matrix[j] = last;
1847 s->chroma_intra_matrix[j] = last;1848 s->chroma_intra_matrix[j] = last;
1848 }1849 }
@@ -1858,14 +1859,14 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 9 unmodified lines
1858 break;1859 break;
1859 1860
1860 last = v;1861 last = v;
1861 j = s->dsp.idct_permutation[ff_zigzag_direct[i]];1862 j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
1862 s->inter_matrix[j] = v;1863 s->inter_matrix[j] = v;
1863 s->chroma_inter_matrix[j] = v;1864 s->chroma_inter_matrix[j] = v;
1864 }1865 }
1865 1866
1866 /* replicate last value */1867 /* replicate last value */
1867 for (; i < 64; i++) {1868 for (; i < 64; i++) {
1868 int j = s->dsp.idct_permutation[ff_zigzag_direct[i]];1869 int j = s->idsp.idct_permutation[ff_zigzag_direct[i]];
1869 s->inter_matrix[j] = last;1870 s->inter_matrix[j] = last;
1870 s->chroma_inter_matrix[j] = last;1871 s->chroma_inter_matrix[j] = last;
1871 }1872 }
@@ -2219,15 +2220,15 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 347 unmodified lines
2219 }2220 }
2220 2221
2221 if (s->alternate_scan) {2222 if (s->alternate_scan) {
2222 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan);2223 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan);
2223 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan);2224 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan);
2224 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);2225 ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
2225 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);2226 ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
2226 } else {2227 } else {
2227 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);2228 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);
2228 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);2229 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
2229 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);2230 ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
2230 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);2231 ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
2231 }2232 }
2232 2233
2233 if (s->pict_type == AV_PICTURE_TYPE_S &&2234 if (s->pict_type == AV_PICTURE_TYPE_S &&
libavcodec/mpeg4videoenc.c+14−14
@@ -110,11 +110,11 @@ static inline void restore_ac_coeffs(MpegEncContext *s, int16_t block[6][64], · 109 unmodified lines
110 if (dir[n]) {110 if (dir[n]) {
111 /* top prediction */111 /* top prediction */
112 for (i = 1; i < 8; i++)112 for (i = 1; i < 8; i++)
113 block[n][s->dsp.idct_permutation[i]] = ac_val[i + 8];113 block[n][s->idsp.idct_permutation[i]] = ac_val[i + 8];
114 } else {114 } else {
115 /* left prediction */115 /* left prediction */
116 for (i = 1; i < 8; i++)116 for (i = 1; i < 8; i++)
117 block[n][s->dsp.idct_permutation[i << 3]] = ac_val[i];117 block[n][s->idsp.idct_permutation[i << 3]] = ac_val[i];
118 }118 }
119 }119 }
120}120}
@@ -152,17 +152,17 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64], · 31 unmodified lines
152 if (s->mb_y == 0 || s->qscale == qscale_table[xy] || n == 2 || n == 3) {152 if (s->mb_y == 0 || s->qscale == qscale_table[xy] || n == 2 || n == 3) {
153 /* same qscale */153 /* same qscale */
154 for (i = 1; i < 8; i++) {154 for (i = 1; i < 8; i++) {
155 const int level = block[n][s->dsp.idct_permutation[i]];155 const int level = block[n][s->idsp.idct_permutation[i]];
156 block[n][s->dsp.idct_permutation[i]] = level - ac_val[i + 8];156 block[n][s->idsp.idct_permutation[i]] = level - ac_val[i + 8];
157 ac_val1[i] = block[n][s->dsp.idct_permutation[i << 3]];157 ac_val1[i] = block[n][s->idsp.idct_permutation[i << 3]];
158 ac_val1[i + 8] = level;158 ac_val1[i + 8] = level;
159 }159 }
160 } else {160 } else {
161 /* different qscale, we must rescale */161 /* different qscale, we must rescale */
162 for (i = 1; i < 8; i++) {162 for (i = 1; i < 8; i++) {
163 const int level = block[n][s->dsp.idct_permutation[i]];163 const int level = block[n][s->idsp.idct_permutation[i]];
164 block[n][s->dsp.idct_permutation[i]] = level - ROUNDED_DIV(ac_val[i + 8] * qscale_table[xy], s->qscale);164 block[n][s->idsp.idct_permutation[i]] = level - ROUNDED_DIV(ac_val[i + 8] * qscale_table[xy], s->qscale);
165 ac_val1[i] = block[n][s->dsp.idct_permutation[i << 3]];165 ac_val1[i] = block[n][s->idsp.idct_permutation[i << 3]];
166 ac_val1[i + 8] = level;166 ac_val1[i + 8] = level;
167 }167 }
168 }168 }
@@ -174,18 +174,18 @@ static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64], · 5 unmodified lines
174 if (s->mb_x == 0 || s->qscale == qscale_table[xy] || n == 1 || n == 3) {174 if (s->mb_x == 0 || s->qscale == qscale_table[xy] || n == 1 || n == 3) {
175 /* same qscale */175 /* same qscale */
176 for (i = 1; i < 8; i++) {176 for (i = 1; i < 8; i++) {
177 const int level = block[n][s->dsp.idct_permutation[i << 3]];177 const int level = block[n][s->idsp.idct_permutation[i << 3]];
178 block[n][s->dsp.idct_permutation[i << 3]] = level - ac_val[i];178 block[n][s->idsp.idct_permutation[i << 3]] = level - ac_val[i];
179 ac_val1[i] = level;179 ac_val1[i] = level;
180 ac_val1[i + 8] = block[n][s->dsp.idct_permutation[i]];180 ac_val1[i + 8] = block[n][s->idsp.idct_permutation[i]];
181 }181 }
182 } else {182 } else {
183 /* different qscale, we must rescale */183 /* different qscale, we must rescale */
184 for (i = 1; i < 8; i++) {184 for (i = 1; i < 8; i++) {
185 const int level = block[n][s->dsp.idct_permutation[i << 3]];185 const int level = block[n][s->idsp.idct_permutation[i << 3]];
186 block[n][s->dsp.idct_permutation[i << 3]] = level - ROUNDED_DIV(ac_val[i] * qscale_table[xy], s->qscale);186 block[n][s->idsp.idct_permutation[i << 3]] = level - ROUNDED_DIV(ac_val[i] * qscale_table[xy], s->qscale);
187 ac_val1[i] = level;187 ac_val1[i] = level;
188 ac_val1[i + 8] = block[n][s->dsp.idct_permutation[i]];188 ac_val1[i + 8] = block[n][s->idsp.idct_permutation[i]];
189 }189 }
190 }190 }
191 st[n] = s->intra_v_scantable.permutated;191 st[n] = s->intra_v_scantable.permutated;
libavcodec/mpegvideo.c+27−25
@@ -34,7 +34,7 @@ · 33 unmodified lines
34#include "libavutil/timer.h"34#include "libavutil/timer.h"
35#include "avcodec.h"35#include "avcodec.h"
36#include "blockdsp.h"36#include "blockdsp.h"
37#include "dsputil.h"37#include "idctdsp.h"
38#include "internal.h"38#include "internal.h"
39#include "mathops.h"39#include "mathops.h"
40#include "mpegutils.h"40#include "mpegutils.h"
@@ -380,6 +380,7 @@ av_cold int ff_dct_common_init(MpegEncContext *s) · 339 unmodified lines
380 ff_blockdsp_init(&s->bdsp, s->avctx);380 ff_blockdsp_init(&s->bdsp, s->avctx);
381 ff_dsputil_init(&s->dsp, s->avctx);381 ff_dsputil_init(&s->dsp, s->avctx);
382 ff_hpeldsp_init(&s->hdsp, s->avctx->flags);382 ff_hpeldsp_init(&s->hdsp, s->avctx->flags);
383 ff_idctdsp_init(&s->idsp, s->avctx);
383 ff_mpegvideodsp_init(&s->mdsp);384 ff_mpegvideodsp_init(&s->mdsp);
384 ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);385 ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);
385 386
@@ -403,14 +404,14 @@ av_cold int ff_dct_common_init(MpegEncContext *s) · 17 unmodified lines
403 * note: only wmv uses different ones404 * note: only wmv uses different ones
404 */405 */
405 if (s->alternate_scan) {406 if (s->alternate_scan) {
406 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan);407 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan);
407 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan);408 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan);
408 } else {409 } else {
409 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);410 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);
410 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);411 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
411 }412 }
412 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);413 ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
413 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);414 ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
414 415
415 return 0;416 return 0;
416}417}
@@ -2041,7 +2042,7 @@ static inline void put_dct(MpegEncContext *s, · 1624 unmodified lines
2041 int16_t *block, int i, uint8_t *dest, int line_size, int qscale)2042 int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
2042{2043{
2043 s->dct_unquantize_intra(s, block, i, qscale);2044 s->dct_unquantize_intra(s, block, i, qscale);
2044 s->dsp.idct_put (dest, line_size, block);2045 s->idsp.idct_put(dest, line_size, block);
2045}2046}
2046 2047
2047/* add block[] to dest[] */2048/* add block[] to dest[] */
@@ -2049,7 +2050,7 @@ static inline void add_dct(MpegEncContext *s, · 1 unmodified line
2049 int16_t *block, int i, uint8_t *dest, int line_size)2050 int16_t *block, int i, uint8_t *dest, int line_size)
2050{2051{
2051 if (s->block_last_index[i] >= 0) {2052 if (s->block_last_index[i] >= 0) {
2052 s->dsp.idct_add (dest, line_size, block);2053 s->idsp.idct_add(dest, line_size, block);
2053 }2054 }
2054}2055}
2055 2056
@@ -2059,7 +2060,7 @@ static inline void add_dequant_dct(MpegEncContext *s, · 3 unmodified lines
2059 if (s->block_last_index[i] >= 0) {2060 if (s->block_last_index[i] >= 0) {
2060 s->dct_unquantize_inter(s, block, i, qscale);2061 s->dct_unquantize_inter(s, block, i, qscale);
2061 2062
2062 s->dsp.idct_add (dest, line_size, block);2063 s->idsp.idct_add(dest, line_size, block);
2063 }2064 }
2064}2065}
2065 2066
@@ -2127,7 +2128,8 @@ FF_ENABLE_DEPRECATION_WARNINGS · 61 unmodified lines
2127 av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);2128 av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
2128 for(i=0; i<6; i++){2129 for(i=0; i<6; i++){
2129 for(j=0; j<64; j++){2130 for(j=0; j<64; j++){
2130 av_log(s->avctx, AV_LOG_DEBUG, "%5d", block[i][s->dsp.idct_permutation[j]]);2131 av_log(s->avctx, AV_LOG_DEBUG, "%5d",
2132 block[i][s->idsp.idct_permutation[j]]);
2131 }2133 }
2132 av_log(s->avctx, AV_LOG_DEBUG, "\n");2134 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2133 }2135 }
@@ -2304,29 +2306,29 @@ FF_ENABLE_DEPRECATION_WARNINGS · 170 unmodified lines
2304 }2306 }
2305 }2307 }
2306 }else{2308 }else{
2307 s->dsp.idct_put(dest_y , dct_linesize, block[0]);2309 s->idsp.idct_put(dest_y, dct_linesize, block[0]);
2308 s->dsp.idct_put(dest_y + block_size, dct_linesize, block[1]);2310 s->idsp.idct_put(dest_y + block_size, dct_linesize, block[1]);
2309 s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]);2311 s->idsp.idct_put(dest_y + dct_offset, dct_linesize, block[2]);
2310 s->dsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);2312 s->idsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
2311 2313
2312 if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){2314 if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
2313 if(s->chroma_y_shift){2315 if(s->chroma_y_shift){
2314 s->dsp.idct_put(dest_cb, uvlinesize, block[4]);2316 s->idsp.idct_put(dest_cb, uvlinesize, block[4]);
2315 s->dsp.idct_put(dest_cr, uvlinesize, block[5]);2317 s->idsp.idct_put(dest_cr, uvlinesize, block[5]);
2316 }else{2318 }else{
2317 2319
2318 dct_linesize = uvlinesize << s->interlaced_dct;2320 dct_linesize = uvlinesize << s->interlaced_dct;
2319 dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8;2321 dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize * 8;
2320 2322
2321 s->dsp.idct_put(dest_cb, dct_linesize, block[4]);2323 s->idsp.idct_put(dest_cb, dct_linesize, block[4]);
2322 s->dsp.idct_put(dest_cr, dct_linesize, block[5]);2324 s->idsp.idct_put(dest_cr, dct_linesize, block[5]);
2323 s->dsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);2325 s->idsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
2324 s->dsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);2326 s->idsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
2325 if(!s->chroma_x_shift){//Chroma4442327 if(!s->chroma_x_shift){//Chroma444
2326 s->dsp.idct_put(dest_cb + 8, dct_linesize, block[8]);2328 s->idsp.idct_put(dest_cb + 8, dct_linesize, block[8]);
2327 s->dsp.idct_put(dest_cr + 8, dct_linesize, block[9]);2329 s->idsp.idct_put(dest_cr + 8, dct_linesize, block[9]);
2328 s->dsp.idct_put(dest_cb + 8 + dct_offset, dct_linesize, block[10]);2330 s->idsp.idct_put(dest_cb + 8 + dct_offset, dct_linesize, block[10]);
2329 s->dsp.idct_put(dest_cr + 8 + dct_offset, dct_linesize, block[11]);2331 s->idsp.idct_put(dest_cr + 8 + dct_offset, dct_linesize, block[11]);
2330 }2332 }
2331 }2333 }
2332 }//gray2334 }//gray
libavcodec/mpegvideo.h+2−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
35#include "get_bits.h"35#include "get_bits.h"
36#include "h263dsp.h"36#include "h263dsp.h"
37#include "hpeldsp.h"37#include "hpeldsp.h"
38#include "idctdsp.h"
38#include "mpegvideodsp.h"39#include "mpegvideodsp.h"
39#include "put_bits.h"40#include "put_bits.h"
40#include "ratecontrol.h"41#include "ratecontrol.h"
@@ -352,6 +353,7 @@ typedef struct MpegEncContext { · 311 unmodified lines
352 BlockDSPContext bdsp;353 BlockDSPContext bdsp;
353 DSPContext dsp; ///< pointers for accelerated dsp functions354 DSPContext dsp; ///< pointers for accelerated dsp functions
354 HpelDSPContext hdsp;355 HpelDSPContext hdsp;
356 IDCTDSPContext idsp;
355 MpegVideoDSPContext mdsp;357 MpegVideoDSPContext mdsp;
356 QpelDSPContext qdsp;358 QpelDSPContext qdsp;
357 VideoDSPContext vdsp;359 VideoDSPContext vdsp;
libavcodec/mpegvideo_enc.c+11−9
@@ -38,6 +38,7 @@ · 37 unmodified lines
38#include "avcodec.h"38#include "avcodec.h"
39#include "dct.h"39#include "dct.h"
40#include "dsputil.h"40#include "dsputil.h"
41#include "idctdsp.h"
41#include "mpeg12.h"42#include "mpeg12.h"
42#include "mpegvideo.h"43#include "mpegvideo.h"
43#include "h261.h"44#include "h261.h"
@@ -86,7 +87,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], · 42 unmodified lines
86 dsp->fdct == ff_jpeg_fdct_islow_10 ||87 dsp->fdct == ff_jpeg_fdct_islow_10 ||
87 dsp->fdct == ff_faandct) {88 dsp->fdct == ff_faandct) {
88 for (i = 0; i < 64; i++) {89 for (i = 0; i < 64; i++) {
89 const int j = dsp->idct_permutation[i];90 const int j = s->idsp.idct_permutation[i];
90 /* 16 <= qscale * quant_matrix[i] <= 790591 /* 16 <= qscale * quant_matrix[i] <= 7905
91 * Assume x = ff_aanscales[i] * qscale * quant_matrix[i]92 * Assume x = ff_aanscales[i] * qscale * quant_matrix[i]
92 * 19952 <= x <= 24920502693 * 19952 <= x <= 249205026
@@ -98,7 +99,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], · 5 unmodified lines
98 }99 }
99 } else if (dsp->fdct == ff_fdct_ifast) {100 } else if (dsp->fdct == ff_fdct_ifast) {
100 for (i = 0; i < 64; i++) {101 for (i = 0; i < 64; i++) {
101 const int j = dsp->idct_permutation[i];102 const int j = s->idsp.idct_permutation[i];
102 /* 16 <= qscale * quant_matrix[i] <= 7905103 /* 16 <= qscale * quant_matrix[i] <= 7905
103 * Assume x = ff_aanscales[i] * qscale * quant_matrix[i]104 * Assume x = ff_aanscales[i] * qscale * quant_matrix[i]
104 * 19952 <= x <= 249205026105 * 19952 <= x <= 249205026
@@ -111,7 +112,7 @@ void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], · 6 unmodified lines
111 }112 }
112 } else {113 } else {
113 for (i = 0; i < 64; i++) {114 for (i = 0; i < 64; i++) {
114 const int j = dsp->idct_permutation[i];115 const int j = s->idsp.idct_permutation[i];
115 /* We can safely suppose that 16 <= quant_matrix[i] <= 255116 /* We can safely suppose that 16 <= quant_matrix[i] <= 255
116 * Assume x = qscale * quant_matrix[i]117 * Assume x = qscale * quant_matrix[i]
117 * So 16 <= x <= 7905118 * So 16 <= x <= 7905
@@ -755,7 +756,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) · 637 unmodified lines
755 756
756 /* init q matrix */757 /* init q matrix */
757 for (i = 0; i < 64; i++) {758 for (i = 0; i < 64; i++) {
758 int j = s->dsp.idct_permutation[i];759 int j = s->idsp.idct_permutation[i];
759 if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 &&760 if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 &&
760 s->mpeg_quant) {761 s->mpeg_quant) {
761 s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];762 s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
@@ -3360,7 +3361,7 @@ static int encode_picture(MpegEncContext *s, int picture_number) · 2598 unmodified lines
3360 if (s->out_format == FMT_MJPEG) {3361 if (s->out_format == FMT_MJPEG) {
3361 /* for mjpeg, we do include qscale in the matrix */3362 /* for mjpeg, we do include qscale in the matrix */
3362 for(i=1;i<64;i++){3363 for(i=1;i<64;i++){
3363 int j= s->dsp.idct_permutation[i];3364 int j = s->idsp.idct_permutation[i];
3364 3365
3365 s->intra_matrix[j] = av_clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);3366 s->intra_matrix[j] = av_clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
3366 }3367 }
@@ -3589,7 +3590,7 @@ static int dct_quantize_trellis_c(MpegEncContext *s, · 222 unmodified lines
3589 if(s->out_format == FMT_H263){3590 if(s->out_format == FMT_H263){
3590 unquant_coeff= alevel*qmul + qadd;3591 unquant_coeff= alevel*qmul + qadd;
3591 }else{ //MPEG13592 }else{ //MPEG1
3592 j= s->dsp.idct_permutation[ scantable[i] ]; //FIXME optimize3593 j = s->idsp.idct_permutation[scantable[i]]; // FIXME: optimize
3593 if(s->mb_intra){3594 if(s->mb_intra){
3594 unquant_coeff = (int)( alevel * qscale * s->intra_matrix[j]) >> 3;3595 unquant_coeff = (int)( alevel * qscale * s->intra_matrix[j]) >> 3;
3595 unquant_coeff = (unquant_coeff - 1) | 1;3596 unquant_coeff = (unquant_coeff - 1) | 1;
@@ -3795,7 +3796,7 @@ static int messed_sign=0; · 199 unmodified lines
3795#endif3796#endif
3796 3797
3797 if(basis[0][0] == 0)3798 if(basis[0][0] == 0)
3798 build_basis(s->dsp.idct_permutation);3799 build_basis(s->idsp.idct_permutation);
3799 3800
3800 qmul= qscale*2;3801 qmul= qscale*2;
3801 qadd= (qscale-1)|1;3802 qadd= (qscale-1)|1;
@@ -4214,8 +4215,9 @@ int ff_dct_quantize_c(MpegEncContext *s, · 412 unmodified lines
4214 *overflow= s->max_qcoeff < max; //overflow might have happened4215 *overflow= s->max_qcoeff < max; //overflow might have happened
4215 4216
4216 /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */4217 /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
4217 if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)4218 if (s->idsp.idct_permutation_type != FF_NO_IDCT_PERM)
4218 ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);4219 ff_block_permute(block, s->idsp.idct_permutation,
4220 scantable, last_non_zero);
4219 4221
4220 return last_non_zero;4222 return last_non_zero;
4221}4223}
libavcodec/mpegvideo_xvmc.c+1−1
@@ -307,7 +307,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s) · 306 unmodified lines
307 if (s->mb_intra && (render->idct || !render->unsigned_intra))307 if (s->mb_intra && (render->idct || !render->unsigned_intra))
308 *s->pblocks[i][0] -= 1 << 10;308 *s->pblocks[i][0] -= 1 << 10;
309 if (!render->idct) {309 if (!render->idct) {
310 s->dsp.idct(*s->pblocks[i]);310 s->idsp.idct(*s->pblocks[i]);
311 /* It is unclear if MC hardware requires pixel diff values to be311 /* It is unclear if MC hardware requires pixel diff values to be
312 * in the range [-255;255]. TODO: Clipping if such hardware is312 * in the range [-255;255]. TODO: Clipping if such hardware is
313 * ever found. As of now it would only be an unnecessary313 * ever found. As of now it would only be an unnecessary
libavcodec/msmpeg4.c+5−5
@@ -28,7 +28,7 @@ · 27 unmodified lines
28 */28 */
29 29
30#include "avcodec.h"30#include "avcodec.h"
31#include "dsputil.h"31#include "idctdsp.h"
32#include "mpegvideo.h"32#include "mpegvideo.h"
33#include "msmpeg4.h"33#include "msmpeg4.h"
34#include "libavutil/x86/asm.h"34#include "libavutil/x86/asm.h"
@@ -136,10 +136,10 @@ av_cold void ff_msmpeg4_common_init(MpegEncContext *s) · 101 unmodified lines
136 136
137 137
138 if(s->msmpeg4_version>=4){138 if(s->msmpeg4_version>=4){
139 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_wmv1_scantable[1]);139 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_wmv1_scantable[1]);
140 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_wmv1_scantable[2]);140 ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_wmv1_scantable[2]);
141 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_wmv1_scantable[3]);141 ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_wmv1_scantable[3]);
142 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_wmv1_scantable[0]);142 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_wmv1_scantable[0]);
143 }143 }
144 //Note the default tables are set in common_init in mpegvideo.c144 //Note the default tables are set in common_init in mpegvideo.c
145 145
libavcodec/nuv.c+1−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
28#include "libavutil/lzo.h"28#include "libavutil/lzo.h"
29#include "libavutil/imgutils.h"29#include "libavutil/imgutils.h"
30#include "avcodec.h"30#include "avcodec.h"
31#include "idctdsp.h"
31#include "internal.h"32#include "internal.h"
32#include "rtjpeg.h"33#include "rtjpeg.h"
33 34
libavcodec/ppc/Makefile+1−1
@@ -9,6 +9,7 @@ OBJS-$(CONFIG_H264DSP) += ppc/h264dsp.o · 8 unmodified lines
9OBJS-$(CONFIG_H264QPEL) += ppc/h264qpel.o9OBJS-$(CONFIG_H264QPEL) += ppc/h264qpel.o
10OBJS-$(CONFIG_HPELDSP) += ppc/hpeldsp_altivec.o10OBJS-$(CONFIG_HPELDSP) += ppc/hpeldsp_altivec.o
11OBJS-$(CONFIG_HUFFYUVDSP) += ppc/huffyuvdsp_altivec.o11OBJS-$(CONFIG_HUFFYUVDSP) += ppc/huffyuvdsp_altivec.o
12OBJS-$(CONFIG_IDCTDSP) += ppc/idctdsp.o
12OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o13OBJS-$(CONFIG_MPEGAUDIODSP) += ppc/mpegaudiodsp_altivec.o
13OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \14OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o \
14 ppc/mpegvideodsp.o15 ppc/mpegvideodsp.o
@@ -24,7 +25,6 @@ OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_altivec.o · 9 unmodified lines
24 25
25ALTIVEC-OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_altivec.o \26ALTIVEC-OBJS-$(CONFIG_DSPUTIL) += ppc/dsputil_altivec.o \
26 ppc/fdct_altivec.o \27 ppc/fdct_altivec.o \
27 ppc/idct_altivec.o \
28 28
29FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o29FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o
30ALTIVEC-OBJS-$(CONFIG_FFT) += $(FFT-OBJS-yes)30ALTIVEC-OBJS-$(CONFIG_FFT) += $(FFT-OBJS-yes)
libavcodec/ppc/dsputil_altivec.h+0−3
@@ -29,9 +29,6 @@ · 28 unmodified lines
29 29
30void ff_fdct_altivec(int16_t *block);30void ff_fdct_altivec(int16_t *block);
31 31
32void ff_idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
33void ff_idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
34
35void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx,32void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx,
36 unsigned high_bit_depth);33 unsigned high_bit_depth);
37 34
libavcodec/ppc/dsputil_ppc.c+0−6
@@ -42,12 +42,6 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx, · 41 unmodified lines
42 c->fdct = ff_fdct_altivec;42 c->fdct = ff_fdct_altivec;
43 }43 }
44#endif //CONFIG_ENCODERS44#endif //CONFIG_ENCODERS
45 if ((avctx->idct_algo == FF_IDCT_AUTO) ||
46 (avctx->idct_algo == FF_IDCT_ALTIVEC)) {
47 c->idct_put = ff_idct_put_altivec;
48 c->idct_add = ff_idct_add_altivec;
49 c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
50 }
51 }45 }
52 }46 }
53}47}
libavcodec/ppc/idctdsp.crenamed from libavcodec/ppc/idct_altivec.c+27−3
@@ -37,8 +37,13 @@ · 36 unmodified lines
37#include <altivec.h>37#include <altivec.h>
38#endif38#endif
39 39
40#include "libavutil/attributes.h"
41#include "libavutil/cpu.h"
42#include "libavutil/ppc/cpu.h"
40#include "libavutil/ppc/types_altivec.h"43#include "libavutil/ppc/types_altivec.h"
41#include "dsputil_altivec.h"44#include "libavcodec/idctdsp.h"
45
46#if HAVE_ALTIVEC
42 47
43#define IDCT_HALF \48#define IDCT_HALF \
44 /* 1st stage */ \49 /* 1st stage */ \
@@ -148,7 +153,7 @@ static const vec_s16 constants[5] = { · 103 unmodified lines
148 { 19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722 }153 { 19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722 }
149};154};
150 155
151void ff_idct_put_altivec(uint8_t *dest, int stride, int16_t *blk)156static void idct_put_altivec(uint8_t *dest, int stride, int16_t *blk)
152{157{
153 vec_s16 *block = (vec_s16 *) blk;158 vec_s16 *block = (vec_s16 *) blk;
154 vec_u8 tmp;159 vec_u8 tmp;
@@ -177,7 +182,7 @@ void ff_idct_put_altivec(uint8_t *dest, int stride, int16_t *blk) · 22 unmodified lines
177 COPY(dest, vx7);182 COPY(dest, vx7);
178}183}
179 184
180void ff_idct_add_altivec(uint8_t *dest, int stride, int16_t *blk)185static void idct_add_altivec(uint8_t *dest, int stride, int16_t *blk)
181{186{
182 vec_s16 *block = (vec_s16 *) blk;187 vec_s16 *block = (vec_s16 *) blk;
183 vec_u8 tmp;188 vec_u8 tmp;
@@ -219,3 +224,22 @@ void ff_idct_add_altivec(uint8_t *dest, int stride, int16_t *blk) · 35 unmodified lines
219 dest += stride;224 dest += stride;
220 ADD(dest, vx7, perm1);225 ADD(dest, vx7, perm1);
221}226}
227
228#endif /* HAVE_ALTIVEC */
229
230av_cold void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx,
231 unsigned high_bit_depth)
232{
233#if HAVE_ALTIVEC
234 if (PPC_ALTIVEC(av_get_cpu_flags())) {
235 if (!high_bit_depth) {
236 if ((avctx->idct_algo == FF_IDCT_AUTO) ||
237 (avctx->idct_algo == FF_IDCT_ALTIVEC)) {
238 c->idct_add = idct_add_altivec;
239 c->idct_put = idct_put_altivec;
240 c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
241 }
242 }
243 }
244#endif /* HAVE_ALTIVEC */
245}
libavcodec/proresdec.c+1−1
@@ -34,7 +34,7 @@ · 33 unmodified lines
34 34
35#include "libavutil/intmath.h"35#include "libavutil/intmath.h"
36#include "avcodec.h"36#include "avcodec.h"
37#include "dsputil.h"37#include "idctdsp.h"
38#include "internal.h"38#include "internal.h"
39#include "proresdata.h"39#include "proresdata.h"
40#include "proresdsp.h"40#include "proresdsp.h"
libavcodec/proresdsp.c+1−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
23#include "config.h"23#include "config.h"
24#include "libavutil/attributes.h"24#include "libavutil/attributes.h"
25#include "libavutil/common.h"25#include "libavutil/common.h"
26#include "dsputil.h"26#include "idctdsp.h"
27#include "proresdsp.h"27#include "proresdsp.h"
28#include "simple_idct.h"28#include "simple_idct.h"
29 29
libavcodec/rtjpeg.c+4−4
@@ -121,7 +121,7 @@ int ff_rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f, · 120 unmodified lines
121 if (res < 0) \121 if (res < 0) \
122 return res; \122 return res; \
123 if (res > 0) \123 if (res > 0) \
124 c->dsp.idct_put(dst, stride, block); \124 c->idsp.idct_put(dst, stride, block); \
125} while (0)125} while (0)
126 int16_t *block = c->block;126 int16_t *block = c->block;
127 BLOCK(c->lquant, y1, f->linesize[0]);127 BLOCK(c->lquant, y1, f->linesize[0]);
@@ -159,7 +159,7 @@ void ff_rtjpeg_decode_init(RTJpegContext *c, int width, int height, · 31 unmodified lines
159 const uint32_t *lquant, const uint32_t *cquant) {159 const uint32_t *lquant, const uint32_t *cquant) {
160 int i;160 int i;
161 for (i = 0; i < 64; i++) {161 for (i = 0; i < 64; i++) {
162 int p = c->dsp.idct_permutation[i];162 int p = c->idsp.idct_permutation[i];
163 c->lquant[p] = lquant[i];163 c->lquant[p] = lquant[i];
164 c->cquant[p] = cquant[i];164 c->cquant[p] = cquant[i];
165 }165 }
@@ -171,13 +171,13 @@ void ff_rtjpeg_init(RTJpegContext *c, AVCodecContext *avctx) · 5 unmodified lines
171{171{
172 int i;172 int i;
173 173
174 ff_dsputil_init(&c->dsp, avctx);174 ff_idctdsp_init(&c->idsp, avctx);
175 175
176 for (i = 0; i < 64; i++) {176 for (i = 0; i < 64; i++) {
177 int z = ff_zigzag_direct[i];177 int z = ff_zigzag_direct[i];
178 z = ((z << 3) | (z >> 3)) & 63; // rtjpeg uses a transposed variant178 z = ((z << 3) | (z >> 3)) & 63; // rtjpeg uses a transposed variant
179 179
180 // permute the scan and quantization tables for the chosen idct180 // permute the scan and quantization tables for the chosen idct
181 c->scan[i] = c->dsp.idct_permutation[z];181 c->scan[i] = c->idsp.idct_permutation[z];
182 }182 }
183}183}
libavcodec/rtjpeg.h+3−2
@@ -23,15 +23,16 @@ · 22 unmodified lines
23#define AVCODEC_RTJPEG_H23#define AVCODEC_RTJPEG_H
24 24
25#include <stdint.h>25#include <stdint.h>
26#include "dsputil.h"26
27#include "libavutil/mem.h"27#include "libavutil/mem.h"
28#include "idctdsp.h"
28 29
29#define RTJPEG_FILE_VERSION 030#define RTJPEG_FILE_VERSION 0
30#define RTJPEG_HEADER_SIZE 1231#define RTJPEG_HEADER_SIZE 12
31 32
32typedef struct RTJpegContext {33typedef struct RTJpegContext {
33 int w, h;34 int w, h;
34 DSPContext dsp;35 IDCTDSPContext idsp;
35 uint8_t scan[64];36 uint8_t scan[64];
36 uint32_t lquant[64];37 uint32_t lquant[64];
37 uint32_t cquant[64];38 uint32_t cquant[64];
libavcodec/vc1dec.c+69−47
@@ -109,24 +109,24 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) · 108 unmodified lines
109 fieldtx = v->fieldtx_plane[topleft_mb_pos];109 fieldtx = v->fieldtx_plane[topleft_mb_pos];
110 stride_y = s->linesize << fieldtx;110 stride_y = s->linesize << fieldtx;
111 v_dist = (16 - fieldtx) >> (fieldtx == 0);111 v_dist = (16 - fieldtx) >> (fieldtx == 0);
112 s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],112 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
113 s->dest[0] - 16 * s->linesize - 16,113 s->dest[0] - 16 * s->linesize - 16,
114 stride_y);114 stride_y);
115 s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],115 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],
116 s->dest[0] - 16 * s->linesize - 8,116 s->dest[0] - 16 * s->linesize - 8,
117 stride_y);117 stride_y);
118 s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],118 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],
119 s->dest[0] - v_dist * s->linesize - 16,119 s->dest[0] - v_dist * s->linesize - 16,
120 stride_y);120 stride_y);
121 s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],121 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],
122 s->dest[0] - v_dist * s->linesize - 8,122 s->dest[0] - v_dist * s->linesize - 8,
123 stride_y);123 stride_y);
124 s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],124 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],
125 s->dest[1] - 8 * s->uvlinesize - 8,125 s->dest[1] - 8 * s->uvlinesize - 8,
126 s->uvlinesize);126 s->uvlinesize);
127 s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],127 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],
128 s->dest[2] - 8 * s->uvlinesize - 8,128 s->dest[2] - 8 * s->uvlinesize - 8,
129 s->uvlinesize);129 s->uvlinesize);
130 }130 }
131 if (s->mb_x == s->mb_width - 1) {131 if (s->mb_x == s->mb_width - 1) {
132 top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x;132 top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x;
@@ -134,24 +134,24 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) · 1 unmodified line
134 fieldtx = v->fieldtx_plane[top_mb_pos];134 fieldtx = v->fieldtx_plane[top_mb_pos];
135 stride_y = s->linesize << fieldtx;135 stride_y = s->linesize << fieldtx;
136 v_dist = fieldtx ? 15 : 8;136 v_dist = fieldtx ? 15 : 8;
137 s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0],137 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0],
138 s->dest[0] - 16 * s->linesize,138 s->dest[0] - 16 * s->linesize,
139 stride_y);139 stride_y);
140 s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1],140 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1],
141 s->dest[0] - 16 * s->linesize + 8,141 s->dest[0] - 16 * s->linesize + 8,
142 stride_y);142 stride_y);
143 s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2],143 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2],
144 s->dest[0] - v_dist * s->linesize,144 s->dest[0] - v_dist * s->linesize,
145 stride_y);145 stride_y);
146 s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],146 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],
147 s->dest[0] - v_dist * s->linesize + 8,147 s->dest[0] - v_dist * s->linesize + 8,
148 stride_y);148 stride_y);
149 s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],149 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],
150 s->dest[1] - 8 * s->uvlinesize,150 s->dest[1] - 8 * s->uvlinesize,
151 s->uvlinesize);151 s->uvlinesize);
152 s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],152 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],
153 s->dest[2] - 8 * s->uvlinesize,153 s->dest[2] - 8 * s->uvlinesize,
154 s->uvlinesize);154 s->uvlinesize);
155 }155 }
156 }156 }
157 157
@@ -3280,7 +3280,7 @@ static int vc1_decode_p_block(VC1Context *v, int16_t block[64], int n, · 3122 unmodified lines
3280 v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);3280 v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
3281 else {3281 else {
3282 v->vc1dsp.vc1_inv_trans_8x8(block);3282 v->vc1dsp.vc1_inv_trans_8x8(block);
3283 s->dsp.add_pixels_clamped(block, dst, linesize);3283 s->idsp.add_pixels_clamped(block, dst, linesize);
3284 }3284 }
3285 }3285 }
3286 break;3286 break;
@@ -3611,7 +3611,10 @@ static int vc1_decode_p_mb(VC1Context *v) · 324 unmodified lines
3611 if (v->rangeredfrm)3611 if (v->rangeredfrm)
3612 for (j = 0; j < 64; j++)3612 for (j = 0; j < 64; j++)
3613 s->block[i][j] <<= 1;3613 s->block[i][j] <<= 1;
3614 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);3614 s->idsp.put_signed_pixels_clamped(s->block[i],
3615 s->dest[dst_idx] + off,
3616 i & 4 ? s->uvlinesize
3617 : s->linesize);
3615 if (v->pq >= 9 && v->overlap) {3618 if (v->pq >= 9 && v->overlap) {
3616 if (v->c_avail)3619 if (v->c_avail)
3617 v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);3620 v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
@@ -3719,8 +3722,10 @@ static int vc1_decode_p_mb(VC1Context *v) · 101 unmodified lines
3719 if (v->rangeredfrm)3722 if (v->rangeredfrm)
3720 for (j = 0; j < 64; j++)3723 for (j = 0; j < 64; j++)
3721 s->block[i][j] <<= 1;3724 s->block[i][j] <<= 1;
3722 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off,3725 s->idsp.put_signed_pixels_clamped(s->block[i],
3723 (i & 4) ? s->uvlinesize : s->linesize);3726 s->dest[dst_idx] + off,
3727 (i & 4) ? s->uvlinesize
3728 : s->linesize);
3724 if (v->pq >= 9 && v->overlap) {3729 if (v->pq >= 9 && v->overlap) {
3725 if (v->c_avail)3730 if (v->c_avail)
3726 v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);3731 v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
@@ -3869,7 +3874,9 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) · 142 unmodified lines
3869 stride_y = s->uvlinesize;3874 stride_y = s->uvlinesize;
3870 off = 0;3875 off = 0;
3871 }3876 }
3872 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);3877 s->idsp.put_signed_pixels_clamped(s->block[i],
3878 s->dest[dst_idx] + off,
3879 stride_y);
3873 //TODO: loop filter3880 //TODO: loop filter
3874 }3881 }
3875 3882
@@ -4031,7 +4038,10 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) · 155 unmodified lines
4031 continue;4038 continue;
4032 v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);4039 v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
4033 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);4040 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
4034 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);4041 s->idsp.put_signed_pixels_clamped(s->block[i],
4042 s->dest[dst_idx] + off,
4043 (i & 4) ? s->uvlinesize
4044 : s->linesize);
4035 // TODO: loop filter4045 // TODO: loop filter
4036 }4046 }
4037 } else {4047 } else {
@@ -4233,7 +4243,10 @@ static void vc1_decode_b_mb(VC1Context *v) · 195 unmodified lines
4233 if (v->rangeredfrm)4243 if (v->rangeredfrm)
4234 for (j = 0; j < 64; j++)4244 for (j = 0; j < 64; j++)
4235 s->block[i][j] <<= 1;4245 s->block[i][j] <<= 1;
4236 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);4246 s->idsp.put_signed_pixels_clamped(s->block[i],
4247 s->dest[dst_idx] + off,
4248 i & 4 ? s->uvlinesize
4249 : s->linesize);
4237 } else if (val) {4250 } else if (val) {
4238 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,4251 vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
4239 first_block, s->dest[dst_idx] + off,4252 first_block, s->dest[dst_idx] + off,
@@ -4305,7 +4318,10 @@ static void vc1_decode_b_mb_intfi(VC1Context *v) · 65 unmodified lines
4305 for (j = 0; j < 64; j++)4318 for (j = 0; j < 64; j++)
4306 s->block[i][j] <<= 1;4319 s->block[i][j] <<= 1;
4307 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);4320 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
4308 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);4321 s->idsp.put_signed_pixels_clamped(s->block[i],
4322 s->dest[dst_idx] + off,
4323 (i & 4) ? s->uvlinesize
4324 : s->linesize);
4309 // TODO: yet to perform loop filter4325 // TODO: yet to perform loop filter
4310 }4326 }
4311 } else {4327 } else {
@@ -4524,7 +4540,9 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) · 212 unmodified lines
4524 stride_y = s->uvlinesize;4540 stride_y = s->uvlinesize;
4525 off = 0;4541 off = 0;
4526 }4542 }
4527 s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);4543 s->idsp.put_signed_pixels_clamped(s->block[i],
4544 s->dest[dst_idx] + off,
4545 stride_y);
4528 }4546 }
4529 } else {4547 } else {
4530 s->mb_intra = v->is_intra[s->mb_x] = 0;4548 s->mb_intra = v->is_intra[s->mb_x] = 0;
@@ -4828,12 +4846,16 @@ static void vc1_decode_i_blocks(VC1Context *v) · 297 unmodified lines
4828 if (v->rangeredfrm)4846 if (v->rangeredfrm)
4829 for (j = 0; j < 64; j++)4847 for (j = 0; j < 64; j++)
4830 s->block[k][j] <<= 1;4848 s->block[k][j] <<= 1;
4831 s->dsp.put_signed_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);4849 s->idsp.put_signed_pixels_clamped(s->block[k], dst[k],
4850 k & 4 ? s->uvlinesize
4851 : s->linesize);
4832 } else {4852 } else {
4833 if (v->rangeredfrm)4853 if (v->rangeredfrm)
4834 for (j = 0; j < 64; j++)4854 for (j = 0; j < 64; j++)
4835 s->block[k][j] = (s->block[k][j] - 64) << 1;4855 s->block[k][j] = (s->block[k][j] - 64) << 1;
4836 s->dsp.put_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);4856 s->idsp.put_pixels_clamped(s->block[k], dst[k],
4857 k & 4 ? s->uvlinesize
4858 : s->linesize);
4837 }4859 }
4838 }4860 }
4839 4861
libavcodec/wmv2.c+12−11
@@ -19,6 +19,7 @@ · 18 unmodified lines
19 */19 */
20 20
21#include "avcodec.h"21#include "avcodec.h"
22#include "idctdsp.h"
22#include "mpegvideo.h"23#include "mpegvideo.h"
23#include "msmpeg4data.h"24#include "msmpeg4data.h"
24#include "simple_idct.h"25#include "simple_idct.h"
@@ -30,24 +31,24 @@ av_cold void ff_wmv2_common_init(Wmv2Context * w){ · 5 unmodified lines
30 31
31 ff_blockdsp_init(&s->bdsp, s->avctx);32 ff_blockdsp_init(&s->bdsp, s->avctx);
32 ff_wmv2dsp_init(&w->wdsp);33 ff_wmv2dsp_init(&w->wdsp);
33 s->dsp.idct_permutation_type = w->wdsp.idct_perm;34 s->idsp.idct_permutation_type = w->wdsp.idct_perm;
34 ff_init_scantable_permutation(s->dsp.idct_permutation,35 ff_init_scantable_permutation(s->idsp.idct_permutation,
35 w->wdsp.idct_perm);36 w->wdsp.idct_perm);
36 ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[0],37 ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[0],
37 ff_wmv2_scantableA);38 ff_wmv2_scantableA);
38 ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[1],39 ff_init_scantable(s->idsp.idct_permutation, &w->abt_scantable[1],
39 ff_wmv2_scantableB);40 ff_wmv2_scantableB);
40 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable,41 ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable,
41 ff_wmv1_scantable[1]);42 ff_wmv1_scantable[1]);
42 ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable,43 ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable,
43 ff_wmv1_scantable[2]);44 ff_wmv1_scantable[2]);
44 ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable,45 ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable,
45 ff_wmv1_scantable[3]);46 ff_wmv1_scantable[3]);
46 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable,47 ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable,
47 ff_wmv1_scantable[0]);48 ff_wmv1_scantable[0]);
48 s->dsp.idct_put = w->wdsp.idct_put;49 s->idsp.idct_put = w->wdsp.idct_put;
49 s->dsp.idct_add = w->wdsp.idct_add;50 s->idsp.idct_add = w->wdsp.idct_add;
50 s->dsp.idct = NULL;51 s->idsp.idct = NULL;
51}52}
52 53
53static void wmv2_add_block(Wmv2Context *w, int16_t *block1, uint8_t *dst, int stride, int n){54static void wmv2_add_block(Wmv2Context *w, int16_t *block1, uint8_t *dst, int stride, int n){
libavcodec/wmv2dsp.c+1−1
@@ -19,7 +19,7 @@ · 18 unmodified lines
19#include "libavutil/attributes.h"19#include "libavutil/attributes.h"
20#include "libavutil/common.h"20#include "libavutil/common.h"
21#include "avcodec.h"21#include "avcodec.h"
22#include "dsputil.h"22#include "idctdsp.h"
23#include "mathops.h"23#include "mathops.h"
24#include "wmv2dsp.h"24#include "wmv2dsp.h"
25 25
libavcodec/x86/Makefile+6−4
@@ -18,6 +18,7 @@ OBJS-$(CONFIG_H264QPEL) += x86/h264_qpel.o · 17 unmodified lines
18OBJS-$(CONFIG_HPELDSP) += x86/hpeldsp_init.o18OBJS-$(CONFIG_HPELDSP) += x86/hpeldsp_init.o
19OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp_init.o19OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp_init.o
20OBJS-$(CONFIG_HUFFYUVENCDSP) += x86/huffyuvencdsp_mmx.o20OBJS-$(CONFIG_HUFFYUVENCDSP) += x86/huffyuvencdsp_mmx.o
21OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_init.o
21OBJS-$(CONFIG_LPC) += x86/lpc.o22OBJS-$(CONFIG_LPC) += x86/lpc.o
22OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodsp.o23OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodsp.o
23OBJS-$(CONFIG_MPEGVIDEO) += x86/mpegvideo.o \24OBJS-$(CONFIG_MPEGVIDEO) += x86/mpegvideo.o \
@@ -49,13 +50,14 @@ OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o · 25 unmodified lines
49 50
50MMX-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_mmx.o51MMX-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_mmx.o
51MMX-OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp_mmx.o52MMX-OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp_mmx.o
52MMX-OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_mmx.o \53MMX-OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_mmx.o
53 x86/idct_mmx_xvid.o \
54 x86/idct_sse2_xvid.o \
55 x86/simple_idct.o
56MMX-OBJS-$(CONFIG_HPELDSP) += x86/fpel_mmx.o \54MMX-OBJS-$(CONFIG_HPELDSP) += x86/fpel_mmx.o \
57 x86/hpeldsp_mmx.o55 x86/hpeldsp_mmx.o
58MMX-OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp_mmx.o56MMX-OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp_mmx.o
57MMX-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_mmx.o \
58 x86/idct_mmx_xvid.o \
59 x86/idct_sse2_xvid.o \
60 x86/simple_idct.o
59MMX-OBJS-$(CONFIG_QPELDSP) += x86/fpel_mmx.o61MMX-OBJS-$(CONFIG_QPELDSP) += x86/fpel_mmx.o
60 62
61MMX-OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc_mmx.o63MMX-OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc_mmx.o
libavcodec/x86/cavsdsp.c+2−1
@@ -28,9 +28,10 @@ · 27 unmodified lines
28#include "libavutil/x86/asm.h"28#include "libavutil/x86/asm.h"
29#include "libavutil/x86/cpu.h"29#include "libavutil/x86/cpu.h"
30#include "libavcodec/cavsdsp.h"30#include "libavcodec/cavsdsp.h"
31#include "libavcodec/idctdsp.h"
31#include "constants.h"32#include "constants.h"
32#include "dsputil_x86.h"
33#include "fpel.h"33#include "fpel.h"
34#include "idctdsp.h"
34#include "config.h"35#include "config.h"
35 36
36#if HAVE_MMX_INLINE37#if HAVE_MMX_INLINE
libavcodec/x86/dsputil_init.c+0−85
@@ -22,97 +22,18 @@ · 21 unmodified lines
22#include "libavutil/x86/cpu.h"22#include "libavutil/x86/cpu.h"
23#include "libavcodec/avcodec.h"23#include "libavcodec/avcodec.h"
24#include "libavcodec/dsputil.h"24#include "libavcodec/dsputil.h"
25#include "libavcodec/simple_idct.h"
26#include "dsputil_x86.h"25#include "dsputil_x86.h"
27#include "idct_xvid.h"
28
29/* Input permutation for the simple_idct_mmx */
30static const uint8_t simple_mmx_permutation[64] = {
31 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
32 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
33 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
34 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
35 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
36 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
37 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
38 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
39};
40
41static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
42
43av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
44 int idct_permutation_type)
45{
46 int i;
47
48 switch (idct_permutation_type) {
49 case FF_SIMPLE_IDCT_PERM:
50 for (i = 0; i < 64; i++)
51 idct_permutation[i] = simple_mmx_permutation[i];
52 return 1;
53 case FF_SSE2_IDCT_PERM:
54 for (i = 0; i < 64; i++)
55 idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
56 return 1;
57 }
58
59 return 0;
60}
61 26
62static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,27static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
63 int cpu_flags, unsigned high_bit_depth)28 int cpu_flags, unsigned high_bit_depth)
64{29{
65#if HAVE_MMX_INLINE30#if HAVE_MMX_INLINE
66 c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
67 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
68 c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
69
70 if (!high_bit_depth) {31 if (!high_bit_depth) {
71 c->draw_edges = ff_draw_edges_mmx;32 c->draw_edges = ff_draw_edges_mmx;
72
73 switch (avctx->idct_algo) {
74 case FF_IDCT_AUTO:
75 case FF_IDCT_SIMPLEMMX:
76 c->idct_put = ff_simple_idct_put_mmx;
77 c->idct_add = ff_simple_idct_add_mmx;
78 c->idct = ff_simple_idct_mmx;
79 c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
80 break;
81 case FF_IDCT_XVIDMMX:
82 c->idct_put = ff_idct_xvid_mmx_put;
83 c->idct_add = ff_idct_xvid_mmx_add;
84 c->idct = ff_idct_xvid_mmx;
85 break;
86 }
87 }33 }
88#endif /* HAVE_MMX_INLINE */34#endif /* HAVE_MMX_INLINE */
89}35}
90 36
91static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
92 int cpu_flags, unsigned high_bit_depth)
93{
94#if HAVE_MMXEXT_INLINE
95 if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
96 c->idct_put = ff_idct_xvid_mmxext_put;
97 c->idct_add = ff_idct_xvid_mmxext_add;
98 c->idct = ff_idct_xvid_mmxext;
99 }
100#endif /* HAVE_MMXEXT_INLINE */
101}
102
103static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
104 int cpu_flags, unsigned high_bit_depth)
105{
106#if HAVE_SSE2_INLINE
107 if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
108 c->idct_put = ff_idct_xvid_sse2_put;
109 c->idct_add = ff_idct_xvid_sse2_add;
110 c->idct = ff_idct_xvid_sse2;
111 c->idct_permutation_type = FF_SSE2_IDCT_PERM;
112 }
113#endif /* HAVE_SSE2_INLINE */
114}
115
116av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,37av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
117 unsigned high_bit_depth)38 unsigned high_bit_depth)
118{39{
@@ -121,12 +42,6 @@ av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx, · 2 unmodified lines
121 if (X86_MMX(cpu_flags))42 if (X86_MMX(cpu_flags))
122 dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);43 dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);
123 44
124 if (X86_MMXEXT(cpu_flags))
125 dsputil_init_mmxext(c, avctx, cpu_flags, high_bit_depth);
126
127 if (X86_SSE2(cpu_flags))
128 dsputil_init_sse2(c, avctx, cpu_flags, high_bit_depth);
129
130 if (CONFIG_ENCODERS)45 if (CONFIG_ENCODERS)
131 ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);46 ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);
132}47}
libavcodec/x86/dsputil_mmx.c+0−135
@@ -30,141 +30,6 @@ · 29 unmodified lines
30 30
31#if HAVE_INLINE_ASM31#if HAVE_INLINE_ASM
32 32
33void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
34 int line_size)
35{
36 const int16_t *p;
37 uint8_t *pix;
38
39 /* read the pixels */
40 p = block;
41 pix = pixels;
42 /* unrolled loop */
43 __asm__ volatile (
44 "movq (%3), %%mm0 \n\t"
45 "movq 8(%3), %%mm1 \n\t"
46 "movq 16(%3), %%mm2 \n\t"
47 "movq 24(%3), %%mm3 \n\t"
48 "movq 32(%3), %%mm4 \n\t"
49 "movq 40(%3), %%mm5 \n\t"
50 "movq 48(%3), %%mm6 \n\t"
51 "movq 56(%3), %%mm7 \n\t"
52 "packuswb %%mm1, %%mm0 \n\t"
53 "packuswb %%mm3, %%mm2 \n\t"
54 "packuswb %%mm5, %%mm4 \n\t"
55 "packuswb %%mm7, %%mm6 \n\t"
56 "movq %%mm0, (%0) \n\t"
57 "movq %%mm2, (%0, %1) \n\t"
58 "movq %%mm4, (%0, %1, 2) \n\t"
59 "movq %%mm6, (%0, %2) \n\t"
60 :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
61 "r" (p)
62 : "memory");
63 pix += line_size * 4;
64 p += 32;
65
66 // if here would be an exact copy of the code above
67 // compiler would generate some very strange code
68 // thus using "r"
69 __asm__ volatile (
70 "movq (%3), %%mm0 \n\t"
71 "movq 8(%3), %%mm1 \n\t"
72 "movq 16(%3), %%mm2 \n\t"
73 "movq 24(%3), %%mm3 \n\t"
74 "movq 32(%3), %%mm4 \n\t"
75 "movq 40(%3), %%mm5 \n\t"
76 "movq 48(%3), %%mm6 \n\t"
77 "movq 56(%3), %%mm7 \n\t"
78 "packuswb %%mm1, %%mm0 \n\t"
79 "packuswb %%mm3, %%mm2 \n\t"
80 "packuswb %%mm5, %%mm4 \n\t"
81 "packuswb %%mm7, %%mm6 \n\t"
82 "movq %%mm0, (%0) \n\t"
83 "movq %%mm2, (%0, %1) \n\t"
84 "movq %%mm4, (%0, %1, 2) \n\t"
85 "movq %%mm6, (%0, %2) \n\t"
86 :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
87 "r" (p)
88 : "memory");
89}
90
91#define put_signed_pixels_clamped_mmx_half(off) \
92 "movq "#off"(%2), %%mm1 \n\t" \
93 "movq 16 + "#off"(%2), %%mm2 \n\t" \
94 "movq 32 + "#off"(%2), %%mm3 \n\t" \
95 "movq 48 + "#off"(%2), %%mm4 \n\t" \
96 "packsswb 8 + "#off"(%2), %%mm1 \n\t" \
97 "packsswb 24 + "#off"(%2), %%mm2 \n\t" \
98 "packsswb 40 + "#off"(%2), %%mm3 \n\t" \
99 "packsswb 56 + "#off"(%2), %%mm4 \n\t" \
100 "paddb %%mm0, %%mm1 \n\t" \
101 "paddb %%mm0, %%mm2 \n\t" \
102 "paddb %%mm0, %%mm3 \n\t" \
103 "paddb %%mm0, %%mm4 \n\t" \
104 "movq %%mm1, (%0) \n\t" \
105 "movq %%mm2, (%0, %3) \n\t" \
106 "movq %%mm3, (%0, %3, 2) \n\t" \
107 "movq %%mm4, (%0, %1) \n\t"
108
109void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
110 int line_size)
111{
112 x86_reg line_skip = line_size;
113 x86_reg line_skip3;
114
115 __asm__ volatile (
116 "movq "MANGLE(ff_pb_80)", %%mm0 \n\t"
117 "lea (%3, %3, 2), %1 \n\t"
118 put_signed_pixels_clamped_mmx_half(0)
119 "lea (%0, %3, 4), %0 \n\t"
120 put_signed_pixels_clamped_mmx_half(64)
121 : "+&r" (pixels), "=&r" (line_skip3)
122 : "r" (block), "r" (line_skip)
123 : "memory");
124}
125
126void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
127 int line_size)
128{
129 const int16_t *p;
130 uint8_t *pix;
131 int i;
132
133 /* read the pixels */
134 p = block;
135 pix = pixels;
136 MOVQ_ZERO(mm7);
137 i = 4;
138 do {
139 __asm__ volatile (
140 "movq (%2), %%mm0 \n\t"
141 "movq 8(%2), %%mm1 \n\t"
142 "movq 16(%2), %%mm2 \n\t"
143 "movq 24(%2), %%mm3 \n\t"
144 "movq %0, %%mm4 \n\t"
145 "movq %1, %%mm6 \n\t"
146 "movq %%mm4, %%mm5 \n\t"
147 "punpcklbw %%mm7, %%mm4 \n\t"
148 "punpckhbw %%mm7, %%mm5 \n\t"
149 "paddsw %%mm4, %%mm0 \n\t"
150 "paddsw %%mm5, %%mm1 \n\t"
151 "movq %%mm6, %%mm5 \n\t"
152 "punpcklbw %%mm7, %%mm6 \n\t"
153 "punpckhbw %%mm7, %%mm5 \n\t"
154 "paddsw %%mm6, %%mm2 \n\t"
155 "paddsw %%mm5, %%mm3 \n\t"
156 "packuswb %%mm1, %%mm0 \n\t"
157 "packuswb %%mm3, %%mm2 \n\t"
158 "movq %%mm0, %0 \n\t"
159 "movq %%mm2, %1 \n\t"
160 : "+m" (*pix), "+m" (*(pix + line_size))
161 : "r" (p)
162 : "memory");
163 pix += line_size * 2;
164 p += 16;
165 } while (--i);
166}
167
168/* Draw the edges of width 'w' of an image of size width, height33/* Draw the edges of width 'w' of an image of size width, height
169 * this MMX version can only handle w == 8 || w == 16. */34 * this MMX version can only handle w == 8 || w == 16. */
170void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,35void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
libavcodec/x86/dsputil_x86.h+0−7
@@ -31,13 +31,6 @@ void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx, · 30 unmodified lines
31 unsigned high_bit_depth);31 unsigned high_bit_depth);
32void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx);32void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx);
33 33
34void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
35 int line_size);
36void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
37 int line_size);
38void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
39 int line_size);
40
41void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,34void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
42 int w, int h, int sides);35 int w, int h, int sides);
43 36
libavcodec/x86/idct_mmx_xvid.c+1−1
@@ -44,8 +44,8 @@ · 43 unmodified lines
44#include "config.h"44#include "config.h"
45#include "libavcodec/avcodec.h"45#include "libavcodec/avcodec.h"
46#include "libavutil/mem.h"46#include "libavutil/mem.h"
47#include "dsputil_x86.h"
48#include "idct_xvid.h"47#include "idct_xvid.h"
48#include "idctdsp.h"
49 49
50#if HAVE_MMX_INLINE50#if HAVE_MMX_INLINE
51 51
libavcodec/x86/idct_sse2_xvid.c+1−1
@@ -42,7 +42,7 @@ · 41 unmodified lines
42#include "libavutil/mem.h"42#include "libavutil/mem.h"
43#include "libavutil/x86/asm.h"43#include "libavutil/x86/asm.h"
44#include "idct_xvid.h"44#include "idct_xvid.h"
45#include "dsputil_x86.h"45#include "idctdsp.h"
46 46
47#if HAVE_SSE2_INLINE47#if HAVE_SSE2_INLINE
48 48
libavcodec/x86/idctdsp.h+31−0
@@ -0,0 +1,31 @@
1/*
2 * This file is part of Libav.
3 *
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVCODEC_X86_IDCTDSP_H
20#define AVCODEC_X86_IDCTDSP_H
21
22#include <stdint.h>
23
24void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
25 int line_size);
26void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
27 int line_size);
28void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
29 int line_size);
30
31#endif /* AVCODEC_X86_IDCTDSP_H */
libavcodec/x86/idctdsp_init.c+106−0
@@ -0,0 +1,106 @@
1/*
2 * This file is part of Libav.
3 *
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20#include "libavutil/attributes.h"
21#include "libavutil/cpu.h"
22#include "libavutil/x86/cpu.h"
23#include "libavcodec/avcodec.h"
24#include "libavcodec/idctdsp.h"
25#include "libavcodec/simple_idct.h"
26#include "idct_xvid.h"
27#include "idctdsp.h"
28
29/* Input permutation for the simple_idct_mmx */
30static const uint8_t simple_mmx_permutation[64] = {
31 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
32 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
33 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
34 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
35 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
36 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
37 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
38 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
39};
40
41static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
42
43av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
44 int idct_permutation_type)
45{
46 int i;
47
48 switch (idct_permutation_type) {
49 case FF_SIMPLE_IDCT_PERM:
50 for (i = 0; i < 64; i++)
51 idct_permutation[i] = simple_mmx_permutation[i];
52 return 1;
53 case FF_SSE2_IDCT_PERM:
54 for (i = 0; i < 64; i++)
55 idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
56 return 1;
57 }
58
59 return 0;
60}
61
62av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
63 unsigned high_bit_depth)
64{
65 int cpu_flags = av_get_cpu_flags();
66
67 if (INLINE_MMX(cpu_flags)) {
68 c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
69 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
70 c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
71
72 if (!high_bit_depth) {
73 switch (avctx->idct_algo) {
74 case FF_IDCT_AUTO:
75 case FF_IDCT_SIMPLEMMX:
76 c->idct_put = ff_simple_idct_put_mmx;
77 c->idct_add = ff_simple_idct_add_mmx;
78 c->idct = ff_simple_idct_mmx;
79 c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
80 break;
81 case FF_IDCT_XVIDMMX:
82 c->idct_put = ff_idct_xvid_mmx_put;
83 c->idct_add = ff_idct_xvid_mmx_add;
84 c->idct = ff_idct_xvid_mmx;
85 break;
86 }
87 }
88 }
89
90 if (INLINE_MMXEXT(cpu_flags)) {
91 if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
92 c->idct_put = ff_idct_xvid_mmxext_put;
93 c->idct_add = ff_idct_xvid_mmxext_add;
94 c->idct = ff_idct_xvid_mmxext;
95 }
96 }
97
98 if (INLINE_SSE2(cpu_flags)) {
99 if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
100 c->idct_put = ff_idct_xvid_sse2_put;
101 c->idct_add = ff_idct_xvid_sse2_add;
102 c->idct = ff_idct_xvid_sse2;
103 c->idct_permutation_type = FF_SSE2_IDCT_PERM;
104 }
105 }
106}
libavcodec/x86/idctdsp_mmx.c+168−0
@@ -0,0 +1,168 @@
1/*
2 * SIMD-optimized IDCT-related routines
3 * Copyright (c) 2000, 2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
7 *
8 * This file is part of Libav.
9 *
10 * Libav is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * Libav is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with Libav; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#include "config.h"
26#include "libavutil/cpu.h"
27#include "libavutil/x86/asm.h"
28#include "idctdsp.h"
29#include "inline_asm.h"
30
31#if HAVE_INLINE_ASM
32
33void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
34 int line_size)
35{
36 const int16_t *p;
37 uint8_t *pix;
38
39 /* read the pixels */
40 p = block;
41 pix = pixels;
42 /* unrolled loop */
43 __asm__ volatile (
44 "movq (%3), %%mm0 \n\t"
45 "movq 8(%3), %%mm1 \n\t"
46 "movq 16(%3), %%mm2 \n\t"
47 "movq 24(%3), %%mm3 \n\t"
48 "movq 32(%3), %%mm4 \n\t"
49 "movq 40(%3), %%mm5 \n\t"
50 "movq 48(%3), %%mm6 \n\t"
51 "movq 56(%3), %%mm7 \n\t"
52 "packuswb %%mm1, %%mm0 \n\t"
53 "packuswb %%mm3, %%mm2 \n\t"
54 "packuswb %%mm5, %%mm4 \n\t"
55 "packuswb %%mm7, %%mm6 \n\t"
56 "movq %%mm0, (%0) \n\t"
57 "movq %%mm2, (%0, %1) \n\t"
58 "movq %%mm4, (%0, %1, 2) \n\t"
59 "movq %%mm6, (%0, %2) \n\t"
60 :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
61 "r" (p)
62 : "memory");
63 pix += line_size * 4;
64 p += 32;
65
66 // if here would be an exact copy of the code above
67 // compiler would generate some very strange code
68 // thus using "r"
69 __asm__ volatile (
70 "movq (%3), %%mm0 \n\t"
71 "movq 8(%3), %%mm1 \n\t"
72 "movq 16(%3), %%mm2 \n\t"
73 "movq 24(%3), %%mm3 \n\t"
74 "movq 32(%3), %%mm4 \n\t"
75 "movq 40(%3), %%mm5 \n\t"
76 "movq 48(%3), %%mm6 \n\t"
77 "movq 56(%3), %%mm7 \n\t"
78 "packuswb %%mm1, %%mm0 \n\t"
79 "packuswb %%mm3, %%mm2 \n\t"
80 "packuswb %%mm5, %%mm4 \n\t"
81 "packuswb %%mm7, %%mm6 \n\t"
82 "movq %%mm0, (%0) \n\t"
83 "movq %%mm2, (%0, %1) \n\t"
84 "movq %%mm4, (%0, %1, 2) \n\t"
85 "movq %%mm6, (%0, %2) \n\t"
86 :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
87 "r" (p)
88 : "memory");
89}
90
91#define put_signed_pixels_clamped_mmx_half(off) \
92 "movq "#off"(%2), %%mm1 \n\t" \
93 "movq 16 + "#off"(%2), %%mm2 \n\t" \
94 "movq 32 + "#off"(%2), %%mm3 \n\t" \
95 "movq 48 + "#off"(%2), %%mm4 \n\t" \
96 "packsswb 8 + "#off"(%2), %%mm1 \n\t" \
97 "packsswb 24 + "#off"(%2), %%mm2 \n\t" \
98 "packsswb 40 + "#off"(%2), %%mm3 \n\t" \
99 "packsswb 56 + "#off"(%2), %%mm4 \n\t" \
100 "paddb %%mm0, %%mm1 \n\t" \
101 "paddb %%mm0, %%mm2 \n\t" \
102 "paddb %%mm0, %%mm3 \n\t" \
103 "paddb %%mm0, %%mm4 \n\t" \
104 "movq %%mm1, (%0) \n\t" \
105 "movq %%mm2, (%0, %3) \n\t" \
106 "movq %%mm3, (%0, %3, 2) \n\t" \
107 "movq %%mm4, (%0, %1) \n\t"
108
109void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
110 int line_size)
111{
112 x86_reg line_skip = line_size;
113 x86_reg line_skip3;
114
115 __asm__ volatile (
116 "movq "MANGLE(ff_pb_80)", %%mm0 \n\t"
117 "lea (%3, %3, 2), %1 \n\t"
118 put_signed_pixels_clamped_mmx_half(0)
119 "lea (%0, %3, 4), %0 \n\t"
120 put_signed_pixels_clamped_mmx_half(64)
121 : "+&r" (pixels), "=&r" (line_skip3)
122 : "r" (block), "r" (line_skip)
123 : "memory");
124}
125
126void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
127 int line_size)
128{
129 const int16_t *p;
130 uint8_t *pix;
131 int i;
132
133 /* read the pixels */
134 p = block;
135 pix = pixels;
136 MOVQ_ZERO(mm7);
137 i = 4;
138 do {
139 __asm__ volatile (
140 "movq (%2), %%mm0 \n\t"
141 "movq 8(%2), %%mm1 \n\t"
142 "movq 16(%2), %%mm2 \n\t"
143 "movq 24(%2), %%mm3 \n\t"
144 "movq %0, %%mm4 \n\t"
145 "movq %1, %%mm6 \n\t"
146 "movq %%mm4, %%mm5 \n\t"
147 "punpcklbw %%mm7, %%mm4 \n\t"
148 "punpckhbw %%mm7, %%mm5 \n\t"
149 "paddsw %%mm4, %%mm0 \n\t"
150 "paddsw %%mm5, %%mm1 \n\t"
151 "movq %%mm6, %%mm5 \n\t"
152 "punpcklbw %%mm7, %%mm6 \n\t"
153 "punpckhbw %%mm7, %%mm5 \n\t"
154 "paddsw %%mm6, %%mm2 \n\t"
155 "paddsw %%mm5, %%mm3 \n\t"
156 "packuswb %%mm1, %%mm0 \n\t"
157 "packuswb %%mm3, %%mm2 \n\t"
158 "movq %%mm0, %0 \n\t"
159 "movq %%mm2, %1 \n\t"
160 : "+m" (*pix), "+m" (*(pix + line_size))
161 : "r" (p)
162 : "memory");
163 pix += line_size * 2;
164 p += 16;
165 } while (--i);
166}
167
168#endif /* HAVE_INLINE_ASM */
libavcodec/x86/mpegvideoenc_template.c+1−1
@@ -229,7 +229,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, · 228 unmodified lines
229 if(s->mb_intra) block[0]= level;229 if(s->mb_intra) block[0]= level;
230 else block[0]= temp_block[0];230 else block[0]= temp_block[0];
231 231
232 if(s->dsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM){232 if (s->idsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM) {
233 if(last_non_zero_p1 <= 1) goto end;233 if(last_non_zero_p1 <= 1) goto end;
234 block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08];234 block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08];
235 block[0x20] = temp_block[0x10];235 block[0x20] = temp_block[0x10];
libavcodec/x86/proresdsp_init.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
22 22
23#include "libavutil/attributes.h"23#include "libavutil/attributes.h"
24#include "libavutil/x86/cpu.h"24#include "libavutil/x86/cpu.h"
25#include "libavcodec/dsputil.h"25#include "libavcodec/idctdsp.h"
26#include "libavcodec/proresdsp.h"26#include "libavcodec/proresdsp.h"
27 27
28void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,28void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
libavcodec/x86/simple_idct.c+1−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
23#include "libavutil/internal.h"23#include "libavutil/internal.h"
24#include "libavutil/mem.h"24#include "libavutil/mem.h"
25#include "libavutil/x86/asm.h"25#include "libavutil/x86/asm.h"
26#include "dsputil_x86.h"26#include "idctdsp.h"
27 27
28#if HAVE_INLINE_ASM28#if HAVE_INLINE_ASM
29 29

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t