History

Merge remote branch 'qatar/master'

* qatar/master: (30 commits) AVOptions: make default_val a union, as proposed in AVOption2. arm/h264pred: add missing argument type. h264dsp_mmx: place bracket outside #if/#endif block. lavf/utils: fix ff_interleave_compare_dts corner case. fate: add 10-bit H264 tests. h264: do not print "too many references" warning for intra-only. Enable decoding of high bit depth h264. Adds 8-, 9- and 10-bit versions of some of the functions used by the h264 decoder. Add support for higher QP values in h264. Add the notion of pixel size in h264 related functions. Make the h264 loop filter bit depth aware. Template dsputil_template.c with respect to pixel size, etc. Template h264idct_template.c with respect to pixel size, etc. Preparatory patch for high bit depth h264 decoding support. Move some functions in dsputil.c into a new file dsputil_template.c. Move the functions in h264idct into a new file h264idct_template.c. Move the functions in h264pred.c into a new file h264pred_template.c. Preparatory patch for high bit depth h264 decoding support. Add pixel formats for 9- and 10-bit yuv420p. Choose h264 chroma dc dequant function dynamically. ... Conflicts: doc/APIchanges ffmpeg.c ffplay.c libavcodec/alpha/dsputil_alpha.c libavcodec/arm/dsputil_init_arm.c libavcodec/arm/dsputil_init_armv6.c libavcodec/arm/dsputil_init_neon.c libavcodec/arm/dsputil_iwmmxt.c libavcodec/arm/h264pred_init_arm.c libavcodec/bfin/dsputil_bfin.c libavcodec/dsputil.c libavcodec/h264.c libavcodec/h264.h libavcodec/h264_cabac.c libavcodec/h264_cavlc.c libavcodec/h264_loopfilter.c libavcodec/h264_ps.c libavcodec/h264_refs.c libavcodec/h264dsp.c libavcodec/h264idct.c libavcodec/h264pred.c libavcodec/mlib/dsputil_mlib.c libavcodec/options.c libavcodec/ppc/dsputil_altivec.c libavcodec/ppc/dsputil_ppc.c libavcodec/ppc/h264_altivec.c libavcodec/ps2/dsputil_mmi.c libavcodec/sh4/dsputil_align.c libavcodec/sh4/dsputil_sh4.c libavcodec/sparc/dsputil_vis.c libavcodec/utils.c libavcodec/version.h libavcodec/x86/dsputil_mmx.c libavformat/options.c libavformat/utils.c libavutil/pixfmt.h libswscale/swscale.c libswscale/swscale_internal.h libswscale/swscale_template.c tests/ref/seek/lavf_avi

Michael Niedermayer committed 15 years ago

Commit 59eb12f2 parents 580fa76 b66752756 files · +3934 −459Browse files

Unified · Split

56 files
  1. doc/APIchanges +6 −0
  2. ffmpeg.c +8 −8
  3. libavcodec/alacenc.c +2 −2
  4. libavcodec/alpha/dsputil_alpha.c +2 −2
  5. libavcodec/arm/dsputil_init_arm.c +2 −2
  6. libavcodec/arm/dsputil_init_armv6.c +2 −2
  7. libavcodec/arm/dsputil_init_neon.c +3 −3
  8. libavcodec/arm/dsputil_iwmmxt.c +2 −2
  9. libavcodec/arm/h264pred_init_arm.c +1 −1
  10. libavcodec/avcodec.h +25 −10
  11. libavcodec/bfin/dsputil_bfin.c +3 −3
  12. libavcodec/dsputil.c +3 −3
  13. libavcodec/dsputil_template.c +1391 −0
  14. libavcodec/flacenc.c +72 −30
  15. libavcodec/h264.c +73 −62
  16. libavcodec/h264.h +5 −5
  17. libavcodec/h264_cabac.c +14 −12
  18. libavcodec/h264_cavlc.c +6 −5
  19. libavcodec/h264_loopfilter.c +59 −165
  20. libavcodec/h264_ps.c +1 −1
  21. libavcodec/h264_refs.c +3 −2
  22. libavcodec/h264dsp.c +54 −50
  23. libavcodec/h264dsp.h +4 −0
  24. libavcodec/h264dsp_template.c +313 −0
  25. libavcodec/h264idct.c +3 −3
  26. libavcodec/h264idct_template.c +291 −0
  27. libavcodec/h264pred.c +343 −21
  28. libavcodec/h264pred_template.c +975 −0
  29. libavcodec/high_bit_depth.h +85 −0
  30. libavcodec/lpc.c +6 −6
  31. libavcodec/lpc.h +14 −3
  32. libavcodec/mlib/dsputil_mlib.c +2 −2
  33. libavcodec/options.c +12 −8
  34. libavcodec/ppc/dsputil_altivec.c +3 −3
  35. libavcodec/ppc/dsputil_ppc.c +2 −2
  36. libavcodec/ppc/h264_altivec.c +2 −2
  37. libavcodec/ps2/dsputil_mmi.c +2 −2
  38. libavcodec/ra144enc.c +2 −2
  39. libavcodec/sh4/dsputil_align.c +4 −4
  40. libavcodec/sh4/dsputil_sh4.c +2 −2
  41. libavcodec/sparc/dsputil_vis.c +2 −2
  42. libavcodec/utils.c +3 −3
  43. libavcodec/version.h +3 −0
  44. libavcodec/x86/dsputil_mmx.c +18 −18
  45. libavformat/utils.c +5 −5
  46. libavutil/opt.h +3 −0
  47. libavutil/pixfmt.h +1 −1
  48. libswscale/utils.c +4 −0
  49. tests/fate/h264.mak +14 −0
  50. tests/ref/fate/h264-conformance-frext-pph10i1_panasonic_a +10 −0
  51. tests/ref/fate/h264-conformance-frext-pph10i2_panasonic_a +10 −0
  52. tests/ref/fate/h264-conformance-frext-pph10i3_panasonic_a +10 −0
  53. tests/ref/fate/h264-conformance-frext-pph10i4_panasonic_a +19 −0
  54. tests/ref/fate/h264-conformance-frext-pph10i5_panasonic_a +10 −0
  55. tests/ref/fate/h264-conformance-frext-pph10i6_panasonic_a +10 −0
  56. tests/ref/fate/h264-conformance-frext-pph10i7_panasonic_a +10 −0
doc/APIchanges+6−0
@@ -13,6 +13,12 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2011-05-10 - xxxxxxx - lavc 53.3.0 - avcodec.h
17+ Deprecate AVLPCType and the following fields in
18+ AVCodecContext: lpc_coeff_precision, prediction_order_method,
19+ min_partition_order, max_partition_order, lpc_type, lpc_passes.
20+ Corresponding FLAC encoder options should be used instead.
21+
1622 2011-05-07 - xxxxxxx - lavfi 2.5.0 - avcodec.h
1723 Add libavfilter/avcodec.h header and avfilter_copy_frame_props()
1824 function.
ffmpeg.c+8−8
@@ -292,7 +292,6 @@ typedef struct AVOutputStream { · 291 unmodified lines
292292 int resample_pix_fmt;
293293
294294 float frame_aspect_ratio;
295−
296295 /* forced key frames */
297296 int64_t *forced_kf_pts;
298297 int forced_kf_count;
@@ -1505,7 +1504,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 1206 unmodified lines
15051504 AVFormatContext *os;
15061505 AVOutputStream *ost;
15071506 int ret, i;
1508− int got_picture;
1507+ int got_output;
15091508 AVFrame picture;
15101509 void *buffer_to_free = NULL;
15111510 static unsigned int samples_size= 0;
@@ -1537,7 +1536,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 25 unmodified lines
15371536 pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
15381537
15391538 //while we have more to decode or while the decoder did output something on EOF
1540− while (avpkt.size > 0 || (!pkt && ist->next_pts != ist->pts)) {
1539+ while (avpkt.size > 0 || (!pkt && got_output)) {
15411540 uint8_t *data_buf, *decoded_data_buf;
15421541 int data_size, decoded_data_size;
15431542 handle_eof:
@@ -1573,9 +1572,10 @@ static int output_packet(AVInputStream *ist, int ist_index, · 29 unmodified lines
15731572 avpkt.data += ret;
15741573 avpkt.size -= ret;
15751574 data_size = ret;
1575+ got_output = decoded_data_size > 0;
15761576 /* Some bug in mpeg audio decoder gives */
15771577 /* decoded_data_size < 0, it seems they are overflows */
1578− if (decoded_data_size <= 0) {
1578+ if (!got_output) {
15791579 /* no audio frame */
15801580 continue;
15811581 }
@@ -1592,11 +1592,11 @@ static int output_packet(AVInputStream *ist, int ist_index, · 10 unmodified lines
15921592 pkt_pts = AV_NOPTS_VALUE;
15931593
15941594 ret = avcodec_decode_video2(ist->st->codec,
1595− &picture, &got_picture, &avpkt);
1595+ &picture, &got_output, &avpkt);
15961596 ist->st->quality= picture.quality;
15971597 if (ret < 0)
15981598 goto fail_decode;
1599− if (!got_picture) {
1599+ if (!got_output) {
16001600 /* no picture yet */
16011601 goto discard_packet;
16021602 }
@@ -1613,10 +1613,10 @@ static int output_packet(AVInputStream *ist, int ist_index, · 10 unmodified lines
16131613 break;
16141614 case AVMEDIA_TYPE_SUBTITLE:
16151615 ret = avcodec_decode_subtitle2(ist->st->codec,
1616− &subtitle, &got_picture, &avpkt);
1616+ &subtitle, &got_output, &avpkt);
16171617 if (ret < 0)
16181618 goto fail_decode;
1619− if (!got_picture) {
1619+ if (!got_output) {
16201620 goto discard_packet;
16211621 }
16221622 subtitle_to_free = &subtitle;
libavcodec/alacenc.c+2−2
@@ -146,7 +146,7 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch) · 145 unmodified lines
146146 s->min_prediction_order,
147147 s->max_prediction_order,
148148 ALAC_MAX_LPC_PRECISION, coefs, shift,
149− AV_LPC_TYPE_LEVINSON, 0,
149+ FF_LPC_TYPE_LEVINSON, 0,
150150 ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
151151
152152 s->lpc[ch].lpc_order = opt_order;
@@ -457,7 +457,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 304 unmodified lines
457457
458458 s->avctx = avctx;
459459 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,
460− AV_LPC_TYPE_LEVINSON);
460+ FF_LPC_TYPE_LEVINSON);
461461
462462 return ret;
463463 }
libavcodec/alpha/dsputil_alpha.c+2−2
@@ -270,9 +270,9 @@ static void put_pixels16_axp_asm(uint8_t *block, const uint8_t *pixels, · 269 unmodified lines
270270
271271 void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
272272 {
273− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
273+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
274274
275− if (!h264_high_depth) {
275+ if (!high_bit_depth) {
276276 c->put_pixels_tab[0][0] = put_pixels16_axp_asm;
277277 c->put_pixels_tab[0][1] = put_pixels16_x2_axp;
278278 c->put_pixels_tab[0][2] = put_pixels16_y2_axp;
libavcodec/arm/dsputil_init_arm.c+2−2
@@ -75,7 +75,7 @@ static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block) · 74 unmodified lines
7575
7676 void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
7777 {
78− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
78+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
7979
8080 ff_put_pixels_clamped = c->put_pixels_clamped;
8181 ff_add_pixels_clamped = c->add_pixels_clamped;
@@ -97,7 +97,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) · 15 unmodified lines
9797
9898 c->add_pixels_clamped = ff_add_pixels_clamped_arm;
9999
100− if (!h264_high_depth) {
100+ if (!high_bit_depth) {
101101 c->put_pixels_tab[0][0] = ff_put_pixels16_arm;
102102 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_arm;
103103 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_arm;
libavcodec/arm/dsputil_init_armv6.c+2−2
@@ -72,7 +72,7 @@ int ff_pix_sum_armv6(uint8_t *pix, int line_size); · 71 unmodified lines
7272
7373 void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)
7474 {
75− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
75+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
7676
7777 if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||
7878 avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
@@ -82,7 +82,7 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) · 3 unmodified lines
8282 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
8383 }
8484
85− if (!h264_high_depth) {
85+ if (!high_bit_depth) {
8686 c->put_pixels_tab[0][0] = ff_put_pixels16_armv6;
8787 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6;
8888 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_armv6;
libavcodec/arm/dsputil_init_neon.c+3−3
@@ -173,7 +173,7 @@ void ff_apply_window_int16_neon(int16_t *dst, const int16_t *src, · 172 unmodified lines
173173
174174 void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
175175 {
176− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
176+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
177177
178178 if (!avctx->lowres) {
179179 if (avctx->idct_algo == FF_IDCT_AUTO ||
@@ -192,7 +192,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) · 12 unmodified lines
192192 }
193193 }
194194
195− if (!h264_high_depth) {
195+ if (!high_bit_depth) {
196196 c->clear_block = ff_clear_block_neon;
197197 c->clear_blocks = ff_clear_blocks_neon;
198198
@@ -223,7 +223,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) · 24 unmodified lines
223223 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon;
224224
225225 if (CONFIG_H264_DECODER) {
226− if (!h264_high_depth) {
226+ if (!high_bit_depth) {
227227 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon;
228228 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon;
229229 c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_neon;
libavcodec/arm/dsputil_iwmmxt.c+2−2
@@ -155,7 +155,7 @@ static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h) · 154 unmodified lines
155155 void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx)
156156 {
157157 int mm_flags = AV_CPU_FLAG_IWMMXT; /* multimedia extension flags */
158− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
158+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
159159
160160 if (avctx->dsp_mask) {
161161 if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
@@ -168,7 +168,7 @@ void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx) · 6 unmodified lines
168168
169169 c->add_pixels_clamped = add_pixels_clamped_iwmmxt;
170170
171− if (!h264_high_depth) {
171+ if (!high_bit_depth) {
172172 c->clear_blocks = clear_blocks_iwmmxt;
173173
174174 c->put_pixels_tab[0][0] = put_pixels16_iwmmxt;
libavcodec/arm/h264pred_init_arm.c+1−1
@@ -74,7 +74,7 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int b · 73 unmodified lines
7474 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon;
7575 }
7676
77−void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth)
77+void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth)
7878 {
7979 if (HAVE_NEON) ff_h264_pred_init_neon(h, codec_id, bit_depth);
8080 }
libavcodec/avcodec.h+25−10
@@ -516,10 +516,11 @@ enum AVChromaLocation{ · 515 unmodified lines
516516 AVCHROMA_LOC_NB , ///< Not part of ABI
517517 };
518518
519+#if FF_API_FLAC_GLOBAL_OPTS
519520 /**
520521 * LPC analysis type
521522 */
522−enum AVLPCType {
523+attribute_deprecated enum AVLPCType {
523524 AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
524525 AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
525526 AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
@@ -527,6 +528,7 @@ enum AVLPCType { · 1 unmodified line
527528 AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
528529 AV_LPC_TYPE_NB , ///< Not part of ABI
529530 };
531+#endif
530532
531533 enum AVAudioServiceType {
532534 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
@@ -2514,42 +2516,53 @@ typedef struct AVCodecContext { · 1981 unmodified lines
25142516 #define FF_COMPRESSION_DEFAULT -1
25152517
25162518 /**
2517− * LPC coefficient precision - used by FLAC encoder
25182519 * - encoding: Set by user.
25192520 * - decoding: unused
25202521 */
2521− int lpc_coeff_precision;
2522+ int min_prediction_order;
25222523
25232524 /**
25242525 * - encoding: Set by user.
25252526 * - decoding: unused
25262527 */
2527− int min_prediction_order;
2528+ int max_prediction_order;
25282529
2530+#if FF_API_FLAC_GLOBAL_OPTS
25292531 /**
2532+ * @defgroup flac_opts FLAC options
2533+ * @deprecated Use FLAC encoder private options instead.
2534+ * @{
2535+ */
2536+
2537+ /**
2538+ * LPC coefficient precision - used by FLAC encoder
25302539 * - encoding: Set by user.
25312540 * - decoding: unused
25322541 */
2533− int max_prediction_order;
2542+ attribute_deprecated int lpc_coeff_precision;
25342543
25352544 /**
25362545 * search method for selecting prediction order
25372546 * - encoding: Set by user.
25382547 * - decoding: unused
25392548 */
2540− int prediction_order_method;
2549+ attribute_deprecated int prediction_order_method;
25412550
25422551 /**
25432552 * - encoding: Set by user.
25442553 * - decoding: unused
25452554 */
2546− int min_partition_order;
2555+ attribute_deprecated int min_partition_order;
25472556
25482557 /**
25492558 * - encoding: Set by user.
25502559 * - decoding: unused
25512560 */
2552− int max_partition_order;
2561+ attribute_deprecated int max_partition_order;
2562+ /**
2563+ * @}
2564+ */
2565+#endif
25532566
25542567 /**
25552568 * GOP timecode frame start number, in non drop frame format
@@ -2767,19 +2780,21 @@ typedef struct AVCodecContext { · 211 unmodified lines
27672780
27682781 int log_level_offset;
27692782
2783+#if FF_API_FLAC_GLOBAL_OPTS
27702784 /**
27712785 * Determines which LPC analysis algorithm to use.
27722786 * - encoding: Set by user
27732787 * - decoding: unused
27742788 */
2775− enum AVLPCType lpc_type;
2789+ attribute_deprecated enum AVLPCType lpc_type;
27762790
27772791 /**
27782792 * Number of passes to use for Cholesky factorization during LPC analysis
27792793 * - encoding: Set by user
27802794 * - decoding: unused
27812795 */
2782− int lpc_passes;
2796+ attribute_deprecated int lpc_passes;
2797+#endif
27832798
27842799 /**
27852800 * Number of slices.
libavcodec/bfin/dsputil_bfin.c+3−3
@@ -197,14 +197,14 @@ static int bfin_pix_abs8_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_si · 196 unmodified lines
197197
198198 void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
199199 {
200− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
200+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
201201
202202 c->get_pixels = ff_bfin_get_pixels;
203203 c->diff_pixels = ff_bfin_diff_pixels;
204204 c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
205205 c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
206206
207− if (!h264_high_depth)
207+ if (!high_bit_depth)
208208 c->clear_blocks = bfin_clear_blocks;
209209 c->pix_sum = ff_bfin_pix_sum;
210210 c->pix_norm1 = ff_bfin_pix_norm1;
@@ -231,7 +231,7 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) · 20 unmodified lines
231231 c->sse[1] = ff_bfin_sse8;
232232 c->sse[2] = ff_bfin_sse4;
233233
234− if (!h264_high_depth) {
234+ if (!high_bit_depth) {
235235 c->put_pixels_tab[0][0] = bfin_put_pixels16;
236236 c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
237237 c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;
libavcodec/dsputil.c+3−3
@@ -43,15 +43,15 @@ uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; · 42 unmodified lines
4343 uint32_t ff_squareTbl[512] = {0, };
4444
4545 #define BIT_DEPTH 9
46−#include "dsputil_internal.h"
46+#include "dsputil_template.c"
4747 #undef BIT_DEPTH
4848
4949 #define BIT_DEPTH 10
50−#include "dsputil_internal.h"
50+#include "dsputil_template.c"
5151 #undef BIT_DEPTH
5252
5353 #define BIT_DEPTH 8
54−#include "dsputil_internal.h"
54+#include "dsputil_template.c"
5555
5656 // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
5757 #define pb_7f (~0UL/255 * 0x7f)
libavcodec/dsputil_template.c+1391−0
@@ -0,0 +1,1391 @@
1+/*
2+ * DSP utils
3+ * Copyright (c) 2000, 2001 Fabrice Bellard
4+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5+ *
6+ * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
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+/**
26+ * @file
27+ * DSP utils
28+ */
29+
30+#include "high_bit_depth.h"
31+
32+static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
33+{
34+ int i;
35+ for(i=0; i<h; i++)
36+ {
37+ AV_WN2P(dst , AV_RN2P(src ));
38+ dst+=dstStride;
39+ src+=srcStride;
40+ }
41+}
42+
43+static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
44+{
45+ int i;
46+ for(i=0; i<h; i++)
47+ {
48+ AV_WN4P(dst , AV_RN4P(src ));
49+ dst+=dstStride;
50+ src+=srcStride;
51+ }
52+}
53+
54+static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
55+{
56+ int i;
57+ for(i=0; i<h; i++)
58+ {
59+ AV_WN4P(dst , AV_RN4P(src ));
60+ AV_WN4P(dst+4*sizeof(pixel), AV_RN4P(src+4*sizeof(pixel)));
61+ dst+=dstStride;
62+ src+=srcStride;
63+ }
64+}
65+
66+static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
67+{
68+ int i;
69+ for(i=0; i<h; i++)
70+ {
71+ AV_WN4P(dst , AV_RN4P(src ));
72+ AV_WN4P(dst+ 4*sizeof(pixel), AV_RN4P(src+ 4*sizeof(pixel)));
73+ AV_WN4P(dst+ 8*sizeof(pixel), AV_RN4P(src+ 8*sizeof(pixel)));
74+ AV_WN4P(dst+12*sizeof(pixel), AV_RN4P(src+12*sizeof(pixel)));
75+ dst+=dstStride;
76+ src+=srcStride;
77+ }
78+}
79+
80+/* draw the edges of width 'w' of an image of size width, height */
81+//FIXME check that this is ok for mpeg4 interlaced
82+static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, int w, int sides)
83+{
84+ pixel *buf = (pixel*)_buf;
85+ int wrap = _wrap / sizeof(pixel);
86+ pixel *ptr, *last_line;
87+ int i;
88+
89+ /* left and right */
90+ ptr = buf;
91+ for(i=0;i<height;i++) {
92+#if BIT_DEPTH > 8
93+ int j;
94+ for (j = 0; j < w; j++) {
95+ ptr[j-w] = ptr[0];
96+ ptr[j+width] = ptr[width-1];
97+ }
98+#else
99+ memset(ptr - w, ptr[0], w);
100+ memset(ptr + width, ptr[width-1], w);
101+#endif
102+ ptr += wrap;
103+ }
104+
105+ /* top and bottom + corners */
106+ buf -= w;
107+ last_line = buf + (height - 1) * wrap;
108+ if (sides & EDGE_TOP)
109+ for(i = 0; i < w; i++)
110+ memcpy(buf - (i + 1) * wrap, buf, (width + w + w) * sizeof(pixel)); // top
111+ if (sides & EDGE_BOTTOM)
112+ for (i = 0; i < w; i++)
113+ memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom
114+}
115+
116+/**
117+ * Copy a rectangular area of samples to a temporary buffer and replicate the border samples.
118+ * @param buf destination buffer
119+ * @param src source buffer
120+ * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
121+ * @param block_w width of block
122+ * @param block_h height of block
123+ * @param src_x x coordinate of the top left sample of the block in the source buffer
124+ * @param src_y y coordinate of the top left sample of the block in the source buffer
125+ * @param w width of the source buffer
126+ * @param h height of the source buffer
127+ */
128+void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, int block_w, int block_h,
129+ int src_x, int src_y, int w, int h){
130+ int x, y;
131+ int start_y, start_x, end_y, end_x;
132+
133+ if(src_y>= h){
134+ src+= (h-1-src_y)*linesize;
135+ src_y=h-1;
136+ }else if(src_y<=-block_h){
137+ src+= (1-block_h-src_y)*linesize;
138+ src_y=1-block_h;
139+ }
140+ if(src_x>= w){
141+ src+= (w-1-src_x)*sizeof(pixel);
142+ src_x=w-1;
143+ }else if(src_x<=-block_w){
144+ src+= (1-block_w-src_x)*sizeof(pixel);
145+ src_x=1-block_w;
146+ }
147+
148+ start_y= FFMAX(0, -src_y);
149+ start_x= FFMAX(0, -src_x);
150+ end_y= FFMIN(block_h, h-src_y);
151+ end_x= FFMIN(block_w, w-src_x);
152+ assert(start_y < end_y && block_h);
153+ assert(start_x < end_x && block_w);
154+
155+ w = end_x - start_x;
156+ src += start_y*linesize + start_x*sizeof(pixel);
157+ buf += start_x*sizeof(pixel);
158+
159+ //top
160+ for(y=0; y<start_y; y++){
161+ memcpy(buf, src, w*sizeof(pixel));
162+ buf += linesize;
163+ }
164+
165+ // copy existing part
166+ for(; y<end_y; y++){
167+ memcpy(buf, src, w*sizeof(pixel));
168+ src += linesize;
169+ buf += linesize;
170+ }
171+
172+ //bottom
173+ src -= linesize;
174+ for(; y<block_h; y++){
175+ memcpy(buf, src, w*sizeof(pixel));
176+ buf += linesize;
177+ }
178+
179+ buf -= block_h * linesize + start_x*sizeof(pixel);
180+ while (block_h--){
181+ pixel *bufp = (pixel*)buf;
182+ //left
183+ for(x=0; x<start_x; x++){
184+ bufp[x] = bufp[start_x];
185+ }
186+
187+ //right
188+ for(x=end_x; x<block_w; x++){
189+ bufp[x] = bufp[end_x - 1];
190+ }
191+ buf += linesize;
192+ }
193+}
194+
195+static void FUNCC(add_pixels8)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size)
196+{
197+ int i;
198+ pixel *restrict pixels = (pixel *restrict)_pixels;
199+ dctcoef *block = (dctcoef*)_block;
200+ line_size /= sizeof(pixel);
201+
202+ for(i=0;i<8;i++) {
203+ pixels[0] += block[0];
204+ pixels[1] += block[1];
205+ pixels[2] += block[2];
206+ pixels[3] += block[3];
207+ pixels[4] += block[4];
208+ pixels[5] += block[5];
209+ pixels[6] += block[6];
210+ pixels[7] += block[7];
211+ pixels += line_size;
212+ block += 8;
213+ }
214+}
215+
216+static void FUNCC(add_pixels4)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size)
217+{
218+ int i;
219+ pixel *restrict pixels = (pixel *restrict)_pixels;
220+ dctcoef *block = (dctcoef*)_block;
221+ line_size /= sizeof(pixel);
222+
223+ for(i=0;i<4;i++) {
224+ pixels[0] += block[0];
225+ pixels[1] += block[1];
226+ pixels[2] += block[2];
227+ pixels[3] += block[3];
228+ pixels += line_size;
229+ block += 4;
230+ }
231+}
232+
233+#if 0
234+
235+#define PIXOP2(OPNAME, OP) \
236+static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
237+{\
238+ int i;\
239+ for(i=0; i<h; i++){\
240+ OP(*((uint64_t*)block), AV_RN64(pixels));\
241+ pixels+=line_size;\
242+ block +=line_size;\
243+ }\
244+}\
245+\
246+static void OPNAME ## _no_rnd_pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
247+{\
248+ int i;\
249+ for(i=0; i<h; i++){\
250+ const uint64_t a= AV_RN64(pixels );\
251+ const uint64_t b= AV_RN64(pixels+1);\
252+ OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
253+ pixels+=line_size;\
254+ block +=line_size;\
255+ }\
256+}\
257+\
258+static void OPNAME ## _pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
259+{\
260+ int i;\
261+ for(i=0; i<h; i++){\
262+ const uint64_t a= AV_RN64(pixels );\
263+ const uint64_t b= AV_RN64(pixels+1);\
264+ OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
265+ pixels+=line_size;\
266+ block +=line_size;\
267+ }\
268+}\
269+\
270+static void OPNAME ## _no_rnd_pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
271+{\
272+ int i;\
273+ for(i=0; i<h; i++){\
274+ const uint64_t a= AV_RN64(pixels );\
275+ const uint64_t b= AV_RN64(pixels+line_size);\
276+ OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
277+ pixels+=line_size;\
278+ block +=line_size;\
279+ }\
280+}\
281+\
282+static void OPNAME ## _pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
283+{\
284+ int i;\
285+ for(i=0; i<h; i++){\
286+ const uint64_t a= AV_RN64(pixels );\
287+ const uint64_t b= AV_RN64(pixels+line_size);\
288+ OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
289+ pixels+=line_size;\
290+ block +=line_size;\
291+ }\
292+}\
293+\
294+static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
295+{\
296+ int i;\
297+ const uint64_t a= AV_RN64(pixels );\
298+ const uint64_t b= AV_RN64(pixels+1);\
299+ uint64_t l0= (a&0x0303030303030303ULL)\
300+ + (b&0x0303030303030303ULL)\
301+ + 0x0202020202020202ULL;\
302+ uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
303+ + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
304+ uint64_t l1,h1;\
305+\
306+ pixels+=line_size;\
307+ for(i=0; i<h; i+=2){\
308+ uint64_t a= AV_RN64(pixels );\
309+ uint64_t b= AV_RN64(pixels+1);\
310+ l1= (a&0x0303030303030303ULL)\
311+ + (b&0x0303030303030303ULL);\
312+ h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
313+ + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
314+ OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
315+ pixels+=line_size;\
316+ block +=line_size;\
317+ a= AV_RN64(pixels );\
318+ b= AV_RN64(pixels+1);\
319+ l0= (a&0x0303030303030303ULL)\
320+ + (b&0x0303030303030303ULL)\
321+ + 0x0202020202020202ULL;\
322+ h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
323+ + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
324+ OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
325+ pixels+=line_size;\
326+ block +=line_size;\
327+ }\
328+}\
329+\
330+static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
331+{\
332+ int i;\
333+ const uint64_t a= AV_RN64(pixels );\
334+ const uint64_t b= AV_RN64(pixels+1);\
335+ uint64_t l0= (a&0x0303030303030303ULL)\
336+ + (b&0x0303030303030303ULL)\
337+ + 0x0101010101010101ULL;\
338+ uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
339+ + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
340+ uint64_t l1,h1;\
341+\
342+ pixels+=line_size;\
343+ for(i=0; i<h; i+=2){\
344+ uint64_t a= AV_RN64(pixels );\
345+ uint64_t b= AV_RN64(pixels+1);\
346+ l1= (a&0x0303030303030303ULL)\
347+ + (b&0x0303030303030303ULL);\
348+ h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
349+ + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
350+ OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
351+ pixels+=line_size;\
352+ block +=line_size;\
353+ a= AV_RN64(pixels );\
354+ b= AV_RN64(pixels+1);\
355+ l0= (a&0x0303030303030303ULL)\
356+ + (b&0x0303030303030303ULL)\
357+ + 0x0101010101010101ULL;\
358+ h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
359+ + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
360+ OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
361+ pixels+=line_size;\
362+ block +=line_size;\
363+ }\
364+}\
365+\
366+CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels_c , 8*sizeof(pixel))\
367+CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8*sizeof(pixel))\
368+CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8*sizeof(pixel))\
369+CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8*sizeof(pixel))\
370+CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8*sizeof(pixel))\
371+CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8*sizeof(pixel))\
372+CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c, 8*sizeof(pixel))
373+
374+#define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) )
375+#else // 64 bit variant
376+
377+#define PIXOP2(OPNAME, OP) \
378+static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
379+ int i;\
380+ for(i=0; i<h; i++){\
381+ OP(*((pixel2*)(block )), AV_RN2P(pixels ));\
382+ pixels+=line_size;\
383+ block +=line_size;\
384+ }\
385+}\
386+static void FUNCC(OPNAME ## _pixels4)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
387+ int i;\
388+ for(i=0; i<h; i++){\
389+ OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
390+ pixels+=line_size;\
391+ block +=line_size;\
392+ }\
393+}\
394+static void FUNCC(OPNAME ## _pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
395+ int i;\
396+ for(i=0; i<h; i++){\
397+ OP(*((pixel4*)(block )), AV_RN4P(pixels ));\
398+ OP(*((pixel4*)(block+4*sizeof(pixel))), AV_RN4P(pixels+4*sizeof(pixel)));\
399+ pixels+=line_size;\
400+ block +=line_size;\
401+ }\
402+}\
403+static inline void FUNCC(OPNAME ## _no_rnd_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
404+ FUNCC(OPNAME ## _pixels8)(block, pixels, line_size, h);\
405+}\
406+\
407+static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
408+ int src_stride1, int src_stride2, int h){\
409+ int i;\
410+ for(i=0; i<h; i++){\
411+ pixel4 a,b;\
412+ a= AV_RN4P(&src1[i*src_stride1 ]);\
413+ b= AV_RN4P(&src2[i*src_stride2 ]);\
414+ OP(*((pixel4*)&dst[i*dst_stride ]), no_rnd_avg_pixel4(a, b));\
415+ a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
416+ b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
417+ OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\
418+ }\
419+}\
420+\
421+static inline void FUNC(OPNAME ## _pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
422+ int src_stride1, int src_stride2, int h){\
423+ int i;\
424+ for(i=0; i<h; i++){\
425+ pixel4 a,b;\
426+ a= AV_RN4P(&src1[i*src_stride1 ]);\
427+ b= AV_RN4P(&src2[i*src_stride2 ]);\
428+ OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
429+ a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
430+ b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
431+ OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), rnd_avg_pixel4(a, b));\
432+ }\
433+}\
434+\
435+static inline void FUNC(OPNAME ## _pixels4_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
436+ int src_stride1, int src_stride2, int h){\
437+ int i;\
438+ for(i=0; i<h; i++){\
439+ pixel4 a,b;\
440+ a= AV_RN4P(&src1[i*src_stride1 ]);\
441+ b= AV_RN4P(&src2[i*src_stride2 ]);\
442+ OP(*((pixel4*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
443+ }\
444+}\
445+\
446+static inline void FUNC(OPNAME ## _pixels2_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
447+ int src_stride1, int src_stride2, int h){\
448+ int i;\
449+ for(i=0; i<h; i++){\
450+ pixel4 a,b;\
451+ a= AV_RN2P(&src1[i*src_stride1 ]);\
452+ b= AV_RN2P(&src2[i*src_stride2 ]);\
453+ OP(*((pixel2*)&dst[i*dst_stride ]), rnd_avg_pixel4(a, b));\
454+ }\
455+}\
456+\
457+static inline void FUNC(OPNAME ## _pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
458+ int src_stride1, int src_stride2, int h){\
459+ FUNC(OPNAME ## _pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
460+ FUNC(OPNAME ## _pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
461+}\
462+\
463+static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
464+ int src_stride1, int src_stride2, int h){\
465+ FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
466+ FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
467+}\
468+\
469+static inline void FUNCC(OPNAME ## _no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
470+ FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
471+}\
472+\
473+static inline void FUNCC(OPNAME ## _pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
474+ FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
475+}\
476+\
477+static inline void FUNCC(OPNAME ## _no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
478+ FUNC(OPNAME ## _no_rnd_pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
479+}\
480+\
481+static inline void FUNCC(OPNAME ## _pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
482+ FUNC(OPNAME ## _pixels8_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
483+}\
484+\
485+static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
486+ int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
487+ /* FIXME HIGH BIT DEPTH */\
488+ int i;\
489+ for(i=0; i<h; i++){\
490+ uint32_t a, b, c, d, l0, l1, h0, h1;\
491+ a= AV_RN32(&src1[i*src_stride1]);\
492+ b= AV_RN32(&src2[i*src_stride2]);\
493+ c= AV_RN32(&src3[i*src_stride3]);\
494+ d= AV_RN32(&src4[i*src_stride4]);\
495+ l0= (a&0x03030303UL)\
496+ + (b&0x03030303UL)\
497+ + 0x02020202UL;\
498+ h0= ((a&0xFCFCFCFCUL)>>2)\
499+ + ((b&0xFCFCFCFCUL)>>2);\
500+ l1= (c&0x03030303UL)\
501+ + (d&0x03030303UL);\
502+ h1= ((c&0xFCFCFCFCUL)>>2)\
503+ + ((d&0xFCFCFCFCUL)>>2);\
504+ OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
505+ a= AV_RN32(&src1[i*src_stride1+4]);\
506+ b= AV_RN32(&src2[i*src_stride2+4]);\
507+ c= AV_RN32(&src3[i*src_stride3+4]);\
508+ d= AV_RN32(&src4[i*src_stride4+4]);\
509+ l0= (a&0x03030303UL)\
510+ + (b&0x03030303UL)\
511+ + 0x02020202UL;\
512+ h0= ((a&0xFCFCFCFCUL)>>2)\
513+ + ((b&0xFCFCFCFCUL)>>2);\
514+ l1= (c&0x03030303UL)\
515+ + (d&0x03030303UL);\
516+ h1= ((c&0xFCFCFCFCUL)>>2)\
517+ + ((d&0xFCFCFCFCUL)>>2);\
518+ OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
519+ }\
520+}\
521+\
522+static inline void FUNCC(OPNAME ## _pixels4_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
523+ FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
524+}\
525+\
526+static inline void FUNCC(OPNAME ## _pixels4_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
527+ FUNC(OPNAME ## _pixels4_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
528+}\
529+\
530+static inline void FUNCC(OPNAME ## _pixels2_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
531+ FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+sizeof(pixel), line_size, line_size, line_size, h);\
532+}\
533+\
534+static inline void FUNCC(OPNAME ## _pixels2_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
535+ FUNC(OPNAME ## _pixels2_l2)(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
536+}\
537+\
538+static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
539+ int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
540+ /* FIXME HIGH BIT DEPTH*/\
541+ int i;\
542+ for(i=0; i<h; i++){\
543+ uint32_t a, b, c, d, l0, l1, h0, h1;\
544+ a= AV_RN32(&src1[i*src_stride1]);\
545+ b= AV_RN32(&src2[i*src_stride2]);\
546+ c= AV_RN32(&src3[i*src_stride3]);\
547+ d= AV_RN32(&src4[i*src_stride4]);\
548+ l0= (a&0x03030303UL)\
549+ + (b&0x03030303UL)\
550+ + 0x01010101UL;\
551+ h0= ((a&0xFCFCFCFCUL)>>2)\
552+ + ((b&0xFCFCFCFCUL)>>2);\
553+ l1= (c&0x03030303UL)\
554+ + (d&0x03030303UL);\
555+ h1= ((c&0xFCFCFCFCUL)>>2)\
556+ + ((d&0xFCFCFCFCUL)>>2);\
557+ OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
558+ a= AV_RN32(&src1[i*src_stride1+4]);\
559+ b= AV_RN32(&src2[i*src_stride2+4]);\
560+ c= AV_RN32(&src3[i*src_stride3+4]);\
561+ d= AV_RN32(&src4[i*src_stride4+4]);\
562+ l0= (a&0x03030303UL)\
563+ + (b&0x03030303UL)\
564+ + 0x01010101UL;\
565+ h0= ((a&0xFCFCFCFCUL)>>2)\
566+ + ((b&0xFCFCFCFCUL)>>2);\
567+ l1= (c&0x03030303UL)\
568+ + (d&0x03030303UL);\
569+ h1= ((c&0xFCFCFCFCUL)>>2)\
570+ + ((d&0xFCFCFCFCUL)>>2);\
571+ OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
572+ }\
573+}\
574+static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
575+ int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
576+ FUNC(OPNAME ## _pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
577+ FUNC(OPNAME ## _pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
578+}\
579+static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
580+ int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
581+ FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
582+ FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
583+}\
584+\
585+static inline void FUNCC(OPNAME ## _pixels2_xy2)(uint8_t *_block, const uint8_t *_pixels, int line_size, int h)\
586+{\
587+ int i, a0, b0, a1, b1;\
588+ pixel *block = (pixel*)_block;\
589+ const pixel *pixels = (const pixel*)_pixels;\
590+ line_size /= sizeof(pixel);\
591+ a0= pixels[0];\
592+ b0= pixels[1] + 2;\
593+ a0 += b0;\
594+ b0 += pixels[2];\
595+\
596+ pixels+=line_size;\
597+ for(i=0; i<h; i+=2){\
598+ a1= pixels[0];\
599+ b1= pixels[1];\
600+ a1 += b1;\
601+ b1 += pixels[2];\
602+\
603+ block[0]= (a1+a0)>>2; /* FIXME non put */\
604+ block[1]= (b1+b0)>>2;\
605+\
606+ pixels+=line_size;\
607+ block +=line_size;\
608+\
609+ a0= pixels[0];\
610+ b0= pixels[1] + 2;\
611+ a0 += b0;\
612+ b0 += pixels[2];\
613+\
614+ block[0]= (a1+a0)>>2;\
615+ block[1]= (b1+b0)>>2;\
616+ pixels+=line_size;\
617+ block +=line_size;\
618+ }\
619+}\
620+\
621+static inline void FUNCC(OPNAME ## _pixels4_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
622+{\
623+ /* FIXME HIGH BIT DEPTH */\
624+ int i;\
625+ const uint32_t a= AV_RN32(pixels );\
626+ const uint32_t b= AV_RN32(pixels+1);\
627+ uint32_t l0= (a&0x03030303UL)\
628+ + (b&0x03030303UL)\
629+ + 0x02020202UL;\
630+ uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
631+ + ((b&0xFCFCFCFCUL)>>2);\
632+ uint32_t l1,h1;\
633+\
634+ pixels+=line_size;\
635+ for(i=0; i<h; i+=2){\
636+ uint32_t a= AV_RN32(pixels );\
637+ uint32_t b= AV_RN32(pixels+1);\
638+ l1= (a&0x03030303UL)\
639+ + (b&0x03030303UL);\
640+ h1= ((a&0xFCFCFCFCUL)>>2)\
641+ + ((b&0xFCFCFCFCUL)>>2);\
642+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
643+ pixels+=line_size;\
644+ block +=line_size;\
645+ a= AV_RN32(pixels );\
646+ b= AV_RN32(pixels+1);\
647+ l0= (a&0x03030303UL)\
648+ + (b&0x03030303UL)\
649+ + 0x02020202UL;\
650+ h0= ((a&0xFCFCFCFCUL)>>2)\
651+ + ((b&0xFCFCFCFCUL)>>2);\
652+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
653+ pixels+=line_size;\
654+ block +=line_size;\
655+ }\
656+}\
657+\
658+static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
659+{\
660+ /* FIXME HIGH BIT DEPTH */\
661+ int j;\
662+ for(j=0; j<2; j++){\
663+ int i;\
664+ const uint32_t a= AV_RN32(pixels );\
665+ const uint32_t b= AV_RN32(pixels+1);\
666+ uint32_t l0= (a&0x03030303UL)\
667+ + (b&0x03030303UL)\
668+ + 0x02020202UL;\
669+ uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
670+ + ((b&0xFCFCFCFCUL)>>2);\
671+ uint32_t l1,h1;\
672+\
673+ pixels+=line_size;\
674+ for(i=0; i<h; i+=2){\
675+ uint32_t a= AV_RN32(pixels );\
676+ uint32_t b= AV_RN32(pixels+1);\
677+ l1= (a&0x03030303UL)\
678+ + (b&0x03030303UL);\
679+ h1= ((a&0xFCFCFCFCUL)>>2)\
680+ + ((b&0xFCFCFCFCUL)>>2);\
681+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
682+ pixels+=line_size;\
683+ block +=line_size;\
684+ a= AV_RN32(pixels );\
685+ b= AV_RN32(pixels+1);\
686+ l0= (a&0x03030303UL)\
687+ + (b&0x03030303UL)\
688+ + 0x02020202UL;\
689+ h0= ((a&0xFCFCFCFCUL)>>2)\
690+ + ((b&0xFCFCFCFCUL)>>2);\
691+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
692+ pixels+=line_size;\
693+ block +=line_size;\
694+ }\
695+ pixels+=4-line_size*(h+1);\
696+ block +=4-line_size*h;\
697+ }\
698+}\
699+\
700+static inline void FUNCC(OPNAME ## _no_rnd_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
701+{\
702+ /* FIXME HIGH BIT DEPTH */\
703+ int j;\
704+ for(j=0; j<2; j++){\
705+ int i;\
706+ const uint32_t a= AV_RN32(pixels );\
707+ const uint32_t b= AV_RN32(pixels+1);\
708+ uint32_t l0= (a&0x03030303UL)\
709+ + (b&0x03030303UL)\
710+ + 0x01010101UL;\
711+ uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
712+ + ((b&0xFCFCFCFCUL)>>2);\
713+ uint32_t l1,h1;\
714+\
715+ pixels+=line_size;\
716+ for(i=0; i<h; i+=2){\
717+ uint32_t a= AV_RN32(pixels );\
718+ uint32_t b= AV_RN32(pixels+1);\
719+ l1= (a&0x03030303UL)\
720+ + (b&0x03030303UL);\
721+ h1= ((a&0xFCFCFCFCUL)>>2)\
722+ + ((b&0xFCFCFCFCUL)>>2);\
723+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
724+ pixels+=line_size;\
725+ block +=line_size;\
726+ a= AV_RN32(pixels );\
727+ b= AV_RN32(pixels+1);\
728+ l0= (a&0x03030303UL)\
729+ + (b&0x03030303UL)\
730+ + 0x01010101UL;\
731+ h0= ((a&0xFCFCFCFCUL)>>2)\
732+ + ((b&0xFCFCFCFCUL)>>2);\
733+ OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
734+ pixels+=line_size;\
735+ block +=line_size;\
736+ }\
737+ pixels+=4-line_size*(h+1);\
738+ block +=4-line_size*h;\
739+ }\
740+}\
741+\
742+CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
743+CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\
744+CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\
745+CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
746+av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
747+CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\
748+CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\
749+CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_xy2), FUNCC(OPNAME ## _no_rnd_pixels8_xy2), 8*sizeof(pixel))\
750+
751+#define op_avg(a, b) a = rnd_avg_pixel4(a, b)
752+#endif
753+#define op_put(a, b) a = b
754+
755+PIXOP2(avg, op_avg)
756+PIXOP2(put, op_put)
757+#undef op_avg
758+#undef op_put
759+
760+#define put_no_rnd_pixels8_c put_pixels8_c
761+#define put_no_rnd_pixels16_c put_pixels16_c
762+
763+static void FUNCC(put_no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
764+ FUNC(put_no_rnd_pixels16_l2)(dst, a, b, stride, stride, stride, h);
765+}
766+
767+static void FUNCC(put_no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
768+ FUNC(put_no_rnd_pixels8_l2)(dst, a, b, stride, stride, stride, h);
769+}
770+
771+#define H264_CHROMA_MC(OPNAME, OP)\
772+static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
773+ pixel *dst = (pixel*)_dst;\
774+ pixel *src = (pixel*)_src;\
775+ const int A=(8-x)*(8-y);\
776+ const int B=( x)*(8-y);\
777+ const int C=(8-x)*( y);\
778+ const int D=( x)*( y);\
779+ int i;\
780+ stride /= sizeof(pixel);\
781+ \
782+ assert(x<8 && y<8 && x>=0 && y>=0);\
783+\
784+ if(D){\
785+ for(i=0; i<h; i++){\
786+ OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
787+ OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
788+ dst+= stride;\
789+ src+= stride;\
790+ }\
791+ }else{\
792+ const int E= B+C;\
793+ const int step= C ? stride : 1;\
794+ for(i=0; i<h; i++){\
795+ OP(dst[0], (A*src[0] + E*src[step+0]));\
796+ OP(dst[1], (A*src[1] + E*src[step+1]));\
797+ dst+= stride;\
798+ src+= stride;\
799+ }\
800+ }\
801+}\
802+\
803+static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
804+ pixel *dst = (pixel*)_dst;\
805+ pixel *src = (pixel*)_src;\
806+ const int A=(8-x)*(8-y);\
807+ const int B=( x)*(8-y);\
808+ const int C=(8-x)*( y);\
809+ const int D=( x)*( y);\
810+ int i;\
811+ stride /= sizeof(pixel);\
812+ \
813+ assert(x<8 && y<8 && x>=0 && y>=0);\
814+\
815+ if(D){\
816+ for(i=0; i<h; i++){\
817+ OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
818+ OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
819+ OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
820+ OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
821+ dst+= stride;\
822+ src+= stride;\
823+ }\
824+ }else{\
825+ const int E= B+C;\
826+ const int step= C ? stride : 1;\
827+ for(i=0; i<h; i++){\
828+ OP(dst[0], (A*src[0] + E*src[step+0]));\
829+ OP(dst[1], (A*src[1] + E*src[step+1]));\
830+ OP(dst[2], (A*src[2] + E*src[step+2]));\
831+ OP(dst[3], (A*src[3] + E*src[step+3]));\
832+ dst+= stride;\
833+ src+= stride;\
834+ }\
835+ }\
836+}\
837+\
838+static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
839+ pixel *dst = (pixel*)_dst;\
840+ pixel *src = (pixel*)_src;\
841+ const int A=(8-x)*(8-y);\
842+ const int B=( x)*(8-y);\
843+ const int C=(8-x)*( y);\
844+ const int D=( x)*( y);\
845+ int i;\
846+ stride /= sizeof(pixel);\
847+ \
848+ assert(x<8 && y<8 && x>=0 && y>=0);\
849+\
850+ if(D){\
851+ for(i=0; i<h; i++){\
852+ OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
853+ OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
854+ OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
855+ OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
856+ OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
857+ OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
858+ OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
859+ OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
860+ dst+= stride;\
861+ src+= stride;\
862+ }\
863+ }else{\
864+ const int E= B+C;\
865+ const int step= C ? stride : 1;\
866+ for(i=0; i<h; i++){\
867+ OP(dst[0], (A*src[0] + E*src[step+0]));\
868+ OP(dst[1], (A*src[1] + E*src[step+1]));\
869+ OP(dst[2], (A*src[2] + E*src[step+2]));\
870+ OP(dst[3], (A*src[3] + E*src[step+3]));\
871+ OP(dst[4], (A*src[4] + E*src[step+4]));\
872+ OP(dst[5], (A*src[5] + E*src[step+5]));\
873+ OP(dst[6], (A*src[6] + E*src[step+6]));\
874+ OP(dst[7], (A*src[7] + E*src[step+7]));\
875+ dst+= stride;\
876+ src+= stride;\
877+ }\
878+ }\
879+}
880+
881+#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
882+#define op_put(a, b) a = (((b) + 32)>>6)
883+
884+H264_CHROMA_MC(put_ , op_put)
885+H264_CHROMA_MC(avg_ , op_avg)
886+#undef op_avg
887+#undef op_put
888+
889+#define H264_LOWPASS(OPNAME, OP, OP2) \
890+static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
891+ const int h=2;\
892+ INIT_CLIP\
893+ int i;\
894+ pixel *dst = (pixel*)_dst;\
895+ pixel *src = (pixel*)_src;\
896+ dstStride /= sizeof(pixel);\
897+ srcStride /= sizeof(pixel);\
898+ for(i=0; i<h; i++)\
899+ {\
900+ OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
901+ OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
902+ dst+=dstStride;\
903+ src+=srcStride;\
904+ }\
905+}\
906+\
907+static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
908+ const int w=2;\
909+ INIT_CLIP\
910+ int i;\
911+ pixel *dst = (pixel*)_dst;\
912+ pixel *src = (pixel*)_src;\
913+ dstStride /= sizeof(pixel);\
914+ srcStride /= sizeof(pixel);\
915+ for(i=0; i<w; i++)\
916+ {\
917+ const int srcB= src[-2*srcStride];\
918+ const int srcA= src[-1*srcStride];\
919+ const int src0= src[0 *srcStride];\
920+ const int src1= src[1 *srcStride];\
921+ const int src2= src[2 *srcStride];\
922+ const int src3= src[3 *srcStride];\
923+ const int src4= src[4 *srcStride];\
924+ OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
925+ OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
926+ dst++;\
927+ src++;\
928+ }\
929+}\
930+\
931+static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\
932+ const int h=2;\
933+ const int w=2;\
934+ const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
935+ INIT_CLIP\
936+ int i;\
937+ pixel *dst = (pixel*)_dst;\
938+ pixel *src = (pixel*)_src;\
939+ dstStride /= sizeof(pixel);\
940+ srcStride /= sizeof(pixel);\
941+ src -= 2*srcStride;\
942+ for(i=0; i<h+5; i++)\
943+ {\
944+ tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
945+ tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
946+ tmp+=tmpStride;\
947+ src+=srcStride;\
948+ }\
949+ tmp -= tmpStride*(h+5-2);\
950+ for(i=0; i<w; i++)\
951+ {\
952+ const int tmpB= tmp[-2*tmpStride] - pad;\
953+ const int tmpA= tmp[-1*tmpStride] - pad;\
954+ const int tmp0= tmp[0 *tmpStride] - pad;\
955+ const int tmp1= tmp[1 *tmpStride] - pad;\
956+ const int tmp2= tmp[2 *tmpStride] - pad;\
957+ const int tmp3= tmp[3 *tmpStride] - pad;\
958+ const int tmp4= tmp[4 *tmpStride] - pad;\
959+ OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
960+ OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
961+ dst++;\
962+ tmp++;\
963+ }\
964+}\
965+static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
966+ const int h=4;\
967+ INIT_CLIP\
968+ int i;\
969+ pixel *dst = (pixel*)_dst;\
970+ pixel *src = (pixel*)_src;\
971+ dstStride /= sizeof(pixel);\
972+ srcStride /= sizeof(pixel);\
973+ for(i=0; i<h; i++)\
974+ {\
975+ OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
976+ OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
977+ OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
978+ OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
979+ dst+=dstStride;\
980+ src+=srcStride;\
981+ }\
982+}\
983+\
984+static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
985+ const int w=4;\
986+ INIT_CLIP\
987+ int i;\
988+ pixel *dst = (pixel*)_dst;\
989+ pixel *src = (pixel*)_src;\
990+ dstStride /= sizeof(pixel);\
991+ srcStride /= sizeof(pixel);\
992+ for(i=0; i<w; i++)\
993+ {\
994+ const int srcB= src[-2*srcStride];\
995+ const int srcA= src[-1*srcStride];\
996+ const int src0= src[0 *srcStride];\
997+ const int src1= src[1 *srcStride];\
998+ const int src2= src[2 *srcStride];\
999+ const int src3= src[3 *srcStride];\
1000+ const int src4= src[4 *srcStride];\
1001+ const int src5= src[5 *srcStride];\
1002+ const int src6= src[6 *srcStride];\
1003+ OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
1004+ OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
1005+ OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
1006+ OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
1007+ dst++;\
1008+ src++;\
1009+ }\
1010+}\
1011+\
1012+static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\
1013+ const int h=4;\
1014+ const int w=4;\
1015+ const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
1016+ INIT_CLIP\
1017+ int i;\
1018+ pixel *dst = (pixel*)_dst;\
1019+ pixel *src = (pixel*)_src;\
1020+ dstStride /= sizeof(pixel);\
1021+ srcStride /= sizeof(pixel);\
1022+ src -= 2*srcStride;\
1023+ for(i=0; i<h+5; i++)\
1024+ {\
1025+ tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
1026+ tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
1027+ tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]) + pad;\
1028+ tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]) + pad;\
1029+ tmp+=tmpStride;\
1030+ src+=srcStride;\
1031+ }\
1032+ tmp -= tmpStride*(h+5-2);\
1033+ for(i=0; i<w; i++)\
1034+ {\
1035+ const int tmpB= tmp[-2*tmpStride] - pad;\
1036+ const int tmpA= tmp[-1*tmpStride] - pad;\
1037+ const int tmp0= tmp[0 *tmpStride] - pad;\
1038+ const int tmp1= tmp[1 *tmpStride] - pad;\
1039+ const int tmp2= tmp[2 *tmpStride] - pad;\
1040+ const int tmp3= tmp[3 *tmpStride] - pad;\
1041+ const int tmp4= tmp[4 *tmpStride] - pad;\
1042+ const int tmp5= tmp[5 *tmpStride] - pad;\
1043+ const int tmp6= tmp[6 *tmpStride] - pad;\
1044+ OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
1045+ OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
1046+ OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
1047+ OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
1048+ dst++;\
1049+ tmp++;\
1050+ }\
1051+}\
1052+\
1053+static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
1054+ const int h=8;\
1055+ INIT_CLIP\
1056+ int i;\
1057+ pixel *dst = (pixel*)_dst;\
1058+ pixel *src = (pixel*)_src;\
1059+ dstStride /= sizeof(pixel);\
1060+ srcStride /= sizeof(pixel);\
1061+ for(i=0; i<h; i++)\
1062+ {\
1063+ OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
1064+ OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
1065+ OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
1066+ OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
1067+ OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
1068+ OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
1069+ OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
1070+ OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
1071+ dst+=dstStride;\
1072+ src+=srcStride;\
1073+ }\
1074+}\
1075+\
1076+static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *_dst, uint8_t *_src, int dstStride, int srcStride){\
1077+ const int w=8;\
1078+ INIT_CLIP\
1079+ int i;\
1080+ pixel *dst = (pixel*)_dst;\
1081+ pixel *src = (pixel*)_src;\
1082+ dstStride /= sizeof(pixel);\
1083+ srcStride /= sizeof(pixel);\
1084+ for(i=0; i<w; i++)\
1085+ {\
1086+ const int srcB= src[-2*srcStride];\
1087+ const int srcA= src[-1*srcStride];\
1088+ const int src0= src[0 *srcStride];\
1089+ const int src1= src[1 *srcStride];\
1090+ const int src2= src[2 *srcStride];\
1091+ const int src3= src[3 *srcStride];\
1092+ const int src4= src[4 *srcStride];\
1093+ const int src5= src[5 *srcStride];\
1094+ const int src6= src[6 *srcStride];\
1095+ const int src7= src[7 *srcStride];\
1096+ const int src8= src[8 *srcStride];\
1097+ const int src9= src[9 *srcStride];\
1098+ const int src10=src[10*srcStride];\
1099+ OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
1100+ OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
1101+ OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
1102+ OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
1103+ OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
1104+ OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
1105+ OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
1106+ OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
1107+ dst++;\
1108+ src++;\
1109+ }\
1110+}\
1111+\
1112+static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *_dst, int16_t *tmp, uint8_t *_src, int dstStride, int tmpStride, int srcStride){\
1113+ const int h=8;\
1114+ const int w=8;\
1115+ const int pad = (BIT_DEPTH > 9) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
1116+ INIT_CLIP\
1117+ int i;\
1118+ pixel *dst = (pixel*)_dst;\
1119+ pixel *src = (pixel*)_src;\
1120+ dstStride /= sizeof(pixel);\
1121+ srcStride /= sizeof(pixel);\
1122+ src -= 2*srcStride;\
1123+ for(i=0; i<h+5; i++)\
1124+ {\
1125+ tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]) + pad;\
1126+ tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]) + pad;\
1127+ tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]) + pad;\
1128+ tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]) + pad;\
1129+ tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]) + pad;\
1130+ tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]) + pad;\
1131+ tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]) + pad;\
1132+ tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]) + pad;\
1133+ tmp+=tmpStride;\
1134+ src+=srcStride;\
1135+ }\
1136+ tmp -= tmpStride*(h+5-2);\
1137+ for(i=0; i<w; i++)\
1138+ {\
1139+ const int tmpB= tmp[-2*tmpStride] - pad;\
1140+ const int tmpA= tmp[-1*tmpStride] - pad;\
1141+ const int tmp0= tmp[0 *tmpStride] - pad;\
1142+ const int tmp1= tmp[1 *tmpStride] - pad;\
1143+ const int tmp2= tmp[2 *tmpStride] - pad;\
1144+ const int tmp3= tmp[3 *tmpStride] - pad;\
1145+ const int tmp4= tmp[4 *tmpStride] - pad;\
1146+ const int tmp5= tmp[5 *tmpStride] - pad;\
1147+ const int tmp6= tmp[6 *tmpStride] - pad;\
1148+ const int tmp7= tmp[7 *tmpStride] - pad;\
1149+ const int tmp8= tmp[8 *tmpStride] - pad;\
1150+ const int tmp9= tmp[9 *tmpStride] - pad;\
1151+ const int tmp10=tmp[10*tmpStride] - pad;\
1152+ OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
1153+ OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
1154+ OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
1155+ OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
1156+ OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
1157+ OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
1158+ OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
1159+ OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
1160+ dst++;\
1161+ tmp++;\
1162+ }\
1163+}\
1164+\
1165+static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1166+ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
1167+ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1168+ src += 8*srcStride;\
1169+ dst += 8*dstStride;\
1170+ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
1171+ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1172+}\
1173+\
1174+static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
1175+ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
1176+ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1177+ src += 8*srcStride;\
1178+ dst += 8*dstStride;\
1179+ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
1180+ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
1181+}\
1182+\
1183+static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
1184+ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
1185+ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1186+ src += 8*srcStride;\
1187+ dst += 8*dstStride;\
1188+ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
1189+ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
1190+}\
1191+
1192+#define H264_MC(OPNAME, SIZE) \
1193+static av_unused void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, uint8_t *src, int stride){\
1194+ FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
1195+}\
1196+\
1197+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, int stride){\
1198+ uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1199+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1200+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1201+}\
1202+\
1203+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, int stride){\
1204+ FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
1205+}\
1206+\
1207+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, int stride){\
1208+ uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1209+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
1210+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
1211+}\
1212+\
1213+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, int stride){\
1214+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1215+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1216+ uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1217+ FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1218+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1219+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1220+}\
1221+\
1222+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, int stride){\
1223+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1224+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1225+ FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1226+ FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
1227+}\
1228+\
1229+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, int stride){\
1230+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1231+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1232+ uint8_t half[SIZE*SIZE*sizeof(pixel)];\
1233+ FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1234+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1235+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1236+}\
1237+\
1238+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, int stride){\
1239+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1240+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1241+ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1242+ uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1243+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1244+ FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1245+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1246+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1247+}\
1248+\
1249+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, int stride){\
1250+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1251+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1252+ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1253+ uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1254+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1255+ FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1256+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1257+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1258+}\
1259+\
1260+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, int stride){\
1261+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1262+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1263+ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1264+ uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1265+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1266+ FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1267+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1268+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1269+}\
1270+\
1271+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, int stride){\
1272+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1273+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1274+ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1275+ uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1276+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1277+ FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1278+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1279+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1280+}\
1281+\
1282+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, int stride){\
1283+ int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1284+ FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
1285+}\
1286+\
1287+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, int stride){\
1288+ int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1289+ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1290+ uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1291+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
1292+ FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1293+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1294+}\
1295+\
1296+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, int stride){\
1297+ int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1298+ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
1299+ uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1300+ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
1301+ FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1302+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1303+}\
1304+\
1305+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, int stride){\
1306+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1307+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1308+ int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1309+ uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1310+ uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1311+ FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
1312+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1313+ FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1314+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1315+}\
1316+\
1317+static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, int stride){\
1318+ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
1319+ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
1320+ int16_t tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
1321+ uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
1322+ uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
1323+ FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
1324+ FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
1325+ FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
1326+ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
1327+}\
1328+
1329+#define op_avg(a, b) a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
1330+//#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
1331+#define op_put(a, b) a = CLIP(((b) + 16)>>5)
1332+#define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
1333+#define op2_put(a, b) a = CLIP(((b) + 512)>>10)
1334+
1335+H264_LOWPASS(put_ , op_put, op2_put)
1336+H264_LOWPASS(avg_ , op_avg, op2_avg)
1337+H264_MC(put_, 2)
1338+H264_MC(put_, 4)
1339+H264_MC(put_, 8)
1340+H264_MC(put_, 16)
1341+H264_MC(avg_, 4)
1342+H264_MC(avg_, 8)
1343+H264_MC(avg_, 16)
1344+
1345+#undef op_avg
1346+#undef op_put
1347+#undef op2_avg
1348+#undef op2_put
1349+
1350+#if BIT_DEPTH == 8
1351+# define put_h264_qpel8_mc00_8_c ff_put_pixels8x8_8_c
1352+# define avg_h264_qpel8_mc00_8_c ff_avg_pixels8x8_8_c
1353+# define put_h264_qpel16_mc00_8_c ff_put_pixels16x16_8_c
1354+# define avg_h264_qpel16_mc00_8_c ff_avg_pixels16x16_8_c
1355+#elif BIT_DEPTH == 9
1356+# define put_h264_qpel8_mc00_9_c ff_put_pixels8x8_9_c
1357+# define avg_h264_qpel8_mc00_9_c ff_avg_pixels8x8_9_c
1358+# define put_h264_qpel16_mc00_9_c ff_put_pixels16x16_9_c
1359+# define avg_h264_qpel16_mc00_9_c ff_avg_pixels16x16_9_c
1360+#elif BIT_DEPTH == 10
1361+# define put_h264_qpel8_mc00_10_c ff_put_pixels8x8_10_c
1362+# define avg_h264_qpel8_mc00_10_c ff_avg_pixels8x8_10_c
1363+# define put_h264_qpel16_mc00_10_c ff_put_pixels16x16_10_c
1364+# define avg_h264_qpel16_mc00_10_c ff_avg_pixels16x16_10_c
1365+#endif
1366+
1367+void FUNCC(ff_put_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1368+ FUNCC(put_pixels8)(dst, src, stride, 8);
1369+}
1370+void FUNCC(ff_avg_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1371+ FUNCC(avg_pixels8)(dst, src, stride, 8);
1372+}
1373+void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1374+ FUNCC(put_pixels16)(dst, src, stride, 16);
1375+}
1376+void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1377+ FUNCC(avg_pixels16)(dst, src, stride, 16);
1378+}
1379+
1380+static void FUNCC(clear_block)(DCTELEM *block)
1381+{
1382+ memset(block, 0, sizeof(dctcoef)*64);
1383+}
1384+
1385+/**
1386+ * memset(blocks, 0, sizeof(DCTELEM)*6*64)
1387+ */
1388+static void FUNCC(clear_blocks)(DCTELEM *blocks)
1389+{
1390+ memset(blocks, 0, sizeof(dctcoef)*6*64);
1391+}
libavcodec/flacenc.c+72−30
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "libavutil/crc.h"
2323 #include "libavutil/md5.h"
24+#include "libavutil/opt.h"
2425 #include "avcodec.h"
2526 #include "get_bits.h"
2627 #include "golomb.h"
@@ -43,7 +44,7 @@ · 16 unmodified lines
4344 typedef struct CompressionOptions {
4445 int compression_level;
4546 int block_time_ms;
46− enum AVLPCType lpc_type;
47+ enum FFLPCType lpc_type;
4748 int lpc_passes;
4849 int lpc_coeff_precision;
4950 int min_prediction_order;
@@ -80,6 +81,7 @@ typedef struct FlacFrame { · 30 unmodified lines
8081 } FlacFrame;
8182
8283 typedef struct FlacEncodeContext {
84+ AVClass *class;
8385 PutBitContext pb;
8486 int channels;
8587 int samplerate;
@@ -156,16 +158,16 @@ static av_cold void dprint_compression_options(FlacEncodeContext *s) · 70 unmodified lines
156158 av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);
157159
158160 switch (opt->lpc_type) {
159− case AV_LPC_TYPE_NONE:
161+ case FF_LPC_TYPE_NONE:
160162 av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n");
161163 break;
162− case AV_LPC_TYPE_FIXED:
164+ case FF_LPC_TYPE_FIXED:
163165 av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n");
164166 break;
165− case AV_LPC_TYPE_LEVINSON:
167+ case FF_LPC_TYPE_LEVINSON:
166168 av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n");
167169 break;
168− case AV_LPC_TYPE_CHOLESKY:
170+ case FF_LPC_TYPE_CHOLESKY:
169171 av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n",
170172 opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");
171173 break;
@@ -266,32 +268,42 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 94 unmodified lines
266268
267269 s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level];
268270
269− s->options.lpc_type = ((int[]){ AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED,
270− AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
271− AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
272− AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,
273− AV_LPC_TYPE_LEVINSON})[level];
271+ if (s->options.lpc_type == FF_LPC_TYPE_DEFAULT)
272+ s->options.lpc_type = ((int[]){ FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED,
273+ FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
274+ FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
275+ FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
276+ FF_LPC_TYPE_LEVINSON})[level];
274277
275278 s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level];
276279 s->options.max_prediction_order = ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level];
277280
278− s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
279− ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
280− ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
281− ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
282− ORDER_METHOD_SEARCH})[level];
281+ if (s->options.prediction_order_method < 0)
282+ s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
283+ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
284+ ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
285+ ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
286+ ORDER_METHOD_SEARCH})[level];
283287
284− s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];
285− s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];
288+ if (s->options.min_partition_order > s->options.max_partition_order) {
289+ av_log(avctx, AV_LOG_ERROR, "invalid partition orders: min=%d max=%d\n",
290+ s->options.min_partition_order, s->options.max_partition_order);
291+ return AVERROR(EINVAL);
292+ }
293+ if (s->options.min_partition_order < 0)
294+ s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];
295+ if (s->options.max_partition_order < 0)
296+ s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];
286297
287298 /* set compression option overrides from AVCodecContext */
288− if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) {
289− if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) {
299+#if FF_API_FLAC_GLOBAL_OPTS
300+ if (avctx->lpc_type > FF_LPC_TYPE_DEFAULT) {
301+ if (avctx->lpc_type > FF_LPC_TYPE_CHOLESKY) {
290302 av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);
291303 return -1;
292304 }
293305 s->options.lpc_type = avctx->lpc_type;
294− if (s->options.lpc_type == AV_LPC_TYPE_CHOLESKY) {
306+ if (s->options.lpc_type == FF_LPC_TYPE_CHOLESKY) {
295307 if (avctx->lpc_passes < 0) {
296308 // default number of passes for Cholesky
297309 s->options.lpc_passes = 2;
@@ -304,11 +316,12 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 6 unmodified lines
304316 }
305317 }
306318 }
319+#endif
307320
308− if (s->options.lpc_type == AV_LPC_TYPE_NONE) {
321+ if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
309322 s->options.min_prediction_order = 0;
310323 } else if (avctx->min_prediction_order >= 0) {
311− if (s->options.lpc_type == AV_LPC_TYPE_FIXED) {
324+ if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
312325 if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
313326 av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
314327 avctx->min_prediction_order);
@@ -322,10 +335,10 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
322335 }
323336 s->options.min_prediction_order = avctx->min_prediction_order;
324337 }
325− if (s->options.lpc_type == AV_LPC_TYPE_NONE) {
338+ if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
326339 s->options.max_prediction_order = 0;
327340 } else if (avctx->max_prediction_order >= 0) {
328− if (s->options.lpc_type == AV_LPC_TYPE_FIXED) {
341+ if (s->options.lpc_type == FF_LPC_TYPE_FIXED) {
329342 if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
330343 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
331344 avctx->max_prediction_order);
@@ -345,6 +358,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 13 unmodified lines
345358 return -1;
346359 }
347360
361+#if FF_API_FLAC_GLOBAL_OPTS
348362 if (avctx->prediction_order_method >= 0) {
349363 if (avctx->prediction_order_method > ORDER_METHOD_LOG) {
350364 av_log(avctx, AV_LOG_ERROR, "invalid prediction order method: %d\n",
@@ -375,6 +389,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 24 unmodified lines
375389 s->options.min_partition_order, s->options.max_partition_order);
376390 return -1;
377391 }
392+#endif
378393
379394 if (avctx->frame_size > 0) {
380395 if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||
@@ -388,6 +403,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
388403 }
389404 s->max_blocksize = s->avctx->frame_size;
390405
406+#if FF_API_FLAC_GLOBAL_OPTS
391407 /* set LPC precision */
392408 if (avctx->lpc_coeff_precision > 0) {
393409 if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
@@ -396,10 +412,8 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 2 unmodified lines
396412 return -1;
397413 }
398414 s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;
399− } else {
400− /* default LPC precision */
401− s->options.lpc_coeff_precision = 15;
402415 }
416+#endif
403417
404418 /* set maximum encoded frame size in verbatim mode */
405419 s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size,
@@ -448,7 +462,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 42 unmodified lines
448462 }
449463
450464 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,
451− s->options.max_prediction_order, AV_LPC_TYPE_LEVINSON);
465+ s->options.max_prediction_order, FF_LPC_TYPE_LEVINSON);
452466
453467 dprint_compression_options(s);
454468
@@ -889,8 +903,8 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch) · 434 unmodified lines
889903
890904 /* FIXED */
891905 sub->type = FLAC_SUBFRAME_FIXED;
892− if (s->options.lpc_type == AV_LPC_TYPE_NONE ||
893− s->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) {
906+ if (s->options.lpc_type == FF_LPC_TYPE_NONE ||
907+ s->options.lpc_type == FF_LPC_TYPE_FIXED || n <= max_order) {
894908 uint32_t bits[MAX_FIXED_ORDER+1];
895909 if (max_order > MAX_FIXED_ORDER)
896910 max_order = MAX_FIXED_ORDER;
@@ -1336,6 +1350,33 @@ static av_cold int flac_encode_close(AVCodecContext *avctx) · 439 unmodified lines
13361350 return 0;
13371351 }
13381352
1353+#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
1354+static const AVOption options[] = {
1355+{ "lpc_coeff_precision", "LPC coefficient precision", offsetof(FlacEncodeContext, options.lpc_coeff_precision), FF_OPT_TYPE_INT, 15, 0, MAX_LPC_PRECISION, FLAGS },
1356+{ "lpc_type", "LPC algorithm", offsetof(FlacEncodeContext, options.lpc_type), FF_OPT_TYPE_INT, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_NB-1, FLAGS, "lpc_type" },
1357+{ "none", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_NONE, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1358+{ "fixed", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_FIXED, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1359+{ "levinson", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1360+{ "cholesky", NULL, 0, FF_OPT_TYPE_CONST, FF_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
1361+{ "lpc_passes", "Number of passes to use for Cholesky factorization during LPC analysis", offsetof(FlacEncodeContext, options.lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, FLAGS },
1362+{ "min_partition_order", NULL, offsetof(FlacEncodeContext, options.min_partition_order), FF_OPT_TYPE_INT, -1, -1, MAX_PARTITION_ORDER, FLAGS },
1363+{ "max_partition_order", NULL, offsetof(FlacEncodeContext, options.max_partition_order), FF_OPT_TYPE_INT, -1, -1, MAX_PARTITION_ORDER, FLAGS },
1364+{ "prediction_order_method", "Search method for selecting prediction order", offsetof(FlacEncodeContext, options.prediction_order_method), FF_OPT_TYPE_INT, -1, -1, ORDER_METHOD_LOG, FLAGS, "predm" },
1365+{ "estimation", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_EST, INT_MIN, INT_MAX, FLAGS, "predm" },
1366+{ "2level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_2LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
1367+{ "4level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_4LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
1368+{ "8level", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_8LEVEL, INT_MIN, INT_MAX, FLAGS, "predm" },
1369+{ "search", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_SEARCH, INT_MIN, INT_MAX, FLAGS, "predm" },
1370+{ "log", NULL, 0, FF_OPT_TYPE_CONST, ORDER_METHOD_LOG, INT_MIN, INT_MAX, FLAGS, "predm" },
1371+{ NULL },
1372+};
1373+
1374+static const AVClass flac_encoder_class = {
1375+ "FLAC encoder",
1376+ av_default_item_name,
1377+ options,
1378+ LIBAVUTIL_VERSION_INT,
1379+};
13391380
13401381 AVCodec ff_flac_encoder = {
13411382 "flac",
@@ -1349,4 +1390,5 @@ AVCodec ff_flac_encoder = { · 7 unmodified lines
13491390 .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
13501391 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
13511392 .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
1393+ .priv_class = &flac_encoder_class,
13521394 };
libavcodec/h264.c+73−62
@@ -45,11 +45,11 @@ · 44 unmodified lines
4545 //#undef NDEBUG
4646 #include <assert.h>
4747
48−static const uint8_t rem6[QP_MAX_MAX+1]={
48+static const uint8_t rem6[QP_MAX_NUM+1]={
4949 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
5050 };
5151
52−static const uint8_t div6[QP_MAX_MAX+1]={
52+static const uint8_t div6[QP_MAX_NUM+1]={
5353 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9,10,10,10,10,
5454 };
5555
@@ -586,6 +586,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){ · 530 unmodified lines
586586
587587 h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
588588 h->pixel_shift = 0;
589+ h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
589590
590591 h->thread_context[0] = h;
591592 h->outputed_poc = h->next_outputed_poc = INT_MIN;
@@ -733,6 +734,7 @@ static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContex · 141 unmodified lines
733734 int ff_h264_frame_start(H264Context *h){
734735 MpegEncContext * const s = &h->s;
735736 int i;
737+ const int pixel_shift = h->pixel_shift;
736738
737739 if(MPV_frame_start(s, s->avctx) < 0)
738740 return -1;
@@ -749,14 +751,14 @@ int ff_h264_frame_start(H264Context *h){ · 10 unmodified lines
749751 assert(s->linesize && s->uvlinesize);
750752
751753 for(i=0; i<16; i++){
752− h->block_offset[i]= (4*((scan8[i] - scan8[0])&7)<<h->pixel_shift) + 4*s->linesize*((scan8[i] - scan8[0])>>3);
753− h->block_offset[24+i]= (4*((scan8[i] - scan8[0])&7)<<h->pixel_shift) + 8*s->linesize*((scan8[i] - scan8[0])>>3);
754+ h->block_offset[i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 4*s->linesize*((scan8[i] - scan8[0])>>3);
755+ h->block_offset[24+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 8*s->linesize*((scan8[i] - scan8[0])>>3);
754756 }
755757 for(i=0; i<4; i++){
756758 h->block_offset[16+i]=
757− h->block_offset[20+i]= (4*((scan8[i] - scan8[0])&7)<<h->pixel_shift) + 4*s->uvlinesize*((scan8[i] - scan8[0])>>3);
759+ h->block_offset[20+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 4*s->uvlinesize*((scan8[i] - scan8[0])>>3);
758760 h->block_offset[24+16+i]=
759− h->block_offset[24+20+i]= (4*((scan8[i] - scan8[0])&7)<<h->pixel_shift) + 8*s->uvlinesize*((scan8[i] - scan8[0])>>3);
761+ h->block_offset[24+20+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 8*s->uvlinesize*((scan8[i] - scan8[0])>>3);
760762 }
761763
762764 /* can't be in alloc_tables because linesize isn't known there.
@@ -948,6 +950,7 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src · 185 unmodified lines
948950 MpegEncContext * const s = &h->s;
949951 uint8_t *top_border;
950952 int top_idx = 1;
953+ const int pixel_shift = h->pixel_shift;
951954
952955 src_y -= linesize;
953956 src_cb -= uvlinesize;
@@ -958,10 +961,10 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src · 4 unmodified lines
958961 if(!MB_MBAFF){
959962 top_border = h->top_borders[0][s->mb_x];
960963 AV_COPY128(top_border, src_y + 15*linesize);
961− if (h->pixel_shift)
964+ if (pixel_shift)
962965 AV_COPY128(top_border+16, src_y+15*linesize+16);
963966 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
964− if (h->pixel_shift) {
967+ if (pixel_shift) {
965968 AV_COPY128(top_border+32, src_cb+7*uvlinesize);
966969 AV_COPY128(top_border+48, src_cr+7*uvlinesize);
967970 } else {
@@ -980,11 +983,11 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src · 12 unmodified lines
980983 // There are two lines saved, the line above the the top macroblock of a pair,
981984 // and the line above the bottom macroblock
982985 AV_COPY128(top_border, src_y + 16*linesize);
983− if (h->pixel_shift)
986+ if (pixel_shift)
984987 AV_COPY128(top_border+16, src_y+16*linesize+16);
985988
986989 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
987− if (h->pixel_shift) {
990+ if (pixel_shift) {
988991 AV_COPY128(top_border+32, src_cb+8*uvlinesize);
989992 AV_COPY128(top_border+48, src_cr+8*uvlinesize);
990993 } else {
@@ -994,7 +997,10 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src · 3 unmodified lines
994997 }
995998 }
996999
997−static inline void xchg_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg, int simple, int pixel_shift){
1000+static inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
1001+ uint8_t *src_cb, uint8_t *src_cr,
1002+ int linesize, int uvlinesize,
1003+ int xchg, int simple, int pixel_shift){
9981004 MpegEncContext * const s = &h->s;
9991005 int deblock_left;
10001006 int deblock_top;
@@ -1040,38 +1046,38 @@ else AV_COPY64(b,a); · 39 unmodified lines
10401046
10411047 if(deblock_top){
10421048 if(deblock_left){
1043− XCHG(top_border_m1+(8<<pixel_shift), src_y -(7<<h->pixel_shift), 1);
1049+ XCHG(top_border_m1 + (8 << pixel_shift), src_y - (7 << pixel_shift), 1);
10441050 }
1045− XCHG(top_border+(0<<pixel_shift), src_y +(1<<pixel_shift), xchg);
1046− XCHG(top_border+(8<<pixel_shift), src_y +(9<<pixel_shift), 1);
1051+ XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
1052+ XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
10471053 if(s->mb_x+1 < s->mb_width){
1048− XCHG(h->top_borders[top_idx][s->mb_x+1], src_y +(17<<pixel_shift), 1);
1054+ XCHG(h->top_borders[top_idx][s->mb_x+1], src_y + (17 << pixel_shift), 1);
10491055 }
10501056 }
10511057 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
10521058 if(deblock_top){
10531059 if(deblock_left){
1054− XCHG(top_border_m1+(16<<pixel_shift), src_cb -(7<<pixel_shift), 1);
1055− XCHG(top_border_m1+(24<<pixel_shift), src_cr -(7<<pixel_shift), 1);
1060+ XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
1061+ XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
10561062 }
1057− XCHG(top_border+(16<<pixel_shift), src_cb+1+pixel_shift, 1);
1058− XCHG(top_border+(24<<pixel_shift), src_cr+1+pixel_shift, 1);
1063+ XCHG(top_border + (16 << pixel_shift), src_cb+1+pixel_shift, 1);
1064+ XCHG(top_border + (24 << pixel_shift), src_cr+1+pixel_shift, 1);
10591065 }
10601066 }
10611067 }
10621068
1063−static av_always_inline int dctcoef_get(H264Context *h, DCTELEM *mb, int index, int pixel_shift) {
1064− if (!pixel_shift)
1065− return mb[index];
1066− else
1067− return ((int32_t*)mb)[index];
1069+static av_always_inline int dctcoef_get(DCTELEM *mb, int high_bit_depth, int index) {
1070+ if (high_bit_depth) {
1071+ return AV_RN32A(((int32_t*)mb) + index);
1072+ } else
1073+ return AV_RN16A(mb + index);
10681074 }
10691075
1070−static av_always_inline void dctcoef_set(H264Context *h, DCTELEM *mb, int index, int value, int pixel_shift) {
1071− if (!pixel_shift)
1072− mb[index] = value;
1073− else
1074− ((int32_t*)mb)[index] = value;
1076+static av_always_inline void dctcoef_set(DCTELEM *mb, int high_bit_depth, int index, int value) {
1077+ if (high_bit_depth) {
1078+ AV_WN32A(((int32_t*)mb) + index, value);
1079+ } else
1080+ AV_WN16A(mb + index, value);
10751081 }
10761082
10771083 static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, int pixel_shift){
@@ -1090,12 +1096,12 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 12 unmodified lines
10901096 void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
10911097 void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
10921098
1093− dest_y = s->current_picture.data[0] + ((mb_x<<pixel_shift) + mb_y * s->linesize ) * 16;
1094− dest_cb = s->current_picture.data[1] + ((mb_x<<pixel_shift) + mb_y * s->uvlinesize) * 8;
1095− dest_cr = s->current_picture.data[2] + ((mb_x<<pixel_shift) + mb_y * s->uvlinesize) * 8;
1099+ dest_y = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16;
1100+ dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
1101+ dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
10961102
1097− s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64<<pixel_shift), s->linesize, 4);
1098− s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + (64<<pixel_shift), dest_cr - dest_cb, 2);
1103+ s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4);
1104+ s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + (64 << pixel_shift), dest_cr - dest_cb, 2);
10991105
11001106 h->list_counts[mb_xy]= h->list_count;
11011107
@@ -1186,16 +1192,16 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 84 unmodified lines
11861192 uint8_t * const ptr= dest_y + block_offset[i];
11871193 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
11881194 if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
1189− h->hpc.pred8x8l_add[dir](ptr, h->mb + (i*16<<pixel_shift), linesize);
1195+ h->hpc.pred8x8l_add[dir](ptr, h->mb + (i*16 << pixel_shift), linesize);
11901196 }else{
11911197 const int nnz = h->non_zero_count_cache[ scan8[i] ];
11921198 h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,
11931199 (h->topright_samples_available<<i)&0x4000, linesize);
11941200 if(nnz){
1195− if(nnz == 1 && dctcoef_get(h, h->mb, i*16, pixel_shift))
1196− idct_dc_add(ptr, h->mb + (i*16<<pixel_shift), linesize);
1201+ if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16))
1202+ idct_dc_add(ptr, h->mb + (i*16 << pixel_shift), linesize);
11971203 else
1198− idct_add (ptr, h->mb + (i*16<<pixel_shift), linesize);
1204+ idct_add (ptr, h->mb + (i*16 << pixel_shift), linesize);
11991205 }
12001206 }
12011207 }
@@ -1212,7 +1218,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 10 unmodified lines
12121218 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
12131219
12141220 if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
1215− h->hpc.pred4x4_add[dir](ptr, h->mb + (i*16<<pixel_shift), linesize);
1221+ h->hpc.pred4x4_add[dir](ptr, h->mb + (i*16 << pixel_shift), linesize);
12161222 }else{
12171223 uint8_t *topright;
12181224 int nnz, tr;
@@ -1229,7 +1235,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 10 unmodified lines
12291235 topright= (uint8_t*) &tr;
12301236 }
12311237 }else
1232− topright= ptr + (4<<pixel_shift) - linesize;
1238+ topright= ptr + (4 << pixel_shift) - linesize;
12331239 }else
12341240 topright= NULL;
12351241
@@ -1237,8 +1243,8 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 1 unmodified line
12371243 nnz = h->non_zero_count_cache[ scan8[i] ];
12381244 if(nnz){
12391245 if(is_h264){
1240− if(nnz == 1 && dctcoef_get(h, h->mb, i*16, pixel_shift))
1241− idct_dc_add(ptr, h->mb + (i*16<<pixel_shift), linesize);
1246+ if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16))
1247+ idct_dc_add(ptr, h->mb + (i*16 << pixel_shift), linesize);
12421248 else
12431249 idct_add (ptr, h->mb + (i*16<<pixel_shift), linesize);
12441250 }
@@ -1261,7 +1267,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 16 unmodified lines
12611267 static const uint8_t dc_mapping[16] = { 0*16, 1*16, 4*16, 5*16, 2*16, 3*16, 6*16, 7*16,
12621268 8*16, 9*16,12*16,13*16,10*16,11*16,14*16,15*16};
12631269 for(i = 0; i < 16; i++)
1264− dctcoef_set(h, h->mb, dc_mapping[i], dctcoef_get(h, h->mb_luma_dc, i,pixel_shift),pixel_shift);
1270+ dctcoef_set(h->mb, pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc, pixel_shift, i));
12651271 }
12661272 }
12671273 }
@@ -1288,8 +1294,8 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 20 unmodified lines
12881294 h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb, linesize);
12891295 }else{
12901296 for(i=0; i<16; i++){
1291− if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h, h->mb, i*16,pixel_shift))
1292− s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + (i*16<<pixel_shift), linesize);
1297+ if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16))
1298+ s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + (i*16 << pixel_shift), linesize);
12931299 }
12941300 }
12951301 }else{
@@ -1301,7 +1307,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 5 unmodified lines
13011307 idct_add= IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4;
13021308 for(i=0; i<16; i+=di){
13031309 if(h->non_zero_count_cache[ scan8[i] ]){
1304− idct_add(dest_y + block_offset[i], h->mb + (i*16<<pixel_shift), linesize);
1310+ idct_add(dest_y + block_offset[i], h->mb + (i*16 << pixel_shift), linesize);
13051311 }
13061312 }
13071313 }else{
@@ -1329,21 +1335,21 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 21 unmodified lines
13291335 uint8_t *dest[2] = {dest_cb, dest_cr};
13301336 if(transform_bypass){
13311337 if(IS_INTRA(mb_type) && h->sps.profile_idc==244 && (h->chroma_pred_mode==VERT_PRED8x8 || h->chroma_pred_mode==HOR_PRED8x8)){
1332− h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0], block_offset + 16, h->mb + (16*16<<pixel_shift), uvlinesize);
1333− h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 20, h->mb + (20*16<<pixel_shift), uvlinesize);
1338+ h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0], block_offset + 16, h->mb + (16*16 << pixel_shift), uvlinesize);
1339+ h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 20, h->mb + (20*16 << pixel_shift), uvlinesize);
13341340 }else{
13351341 idct_add = s->dsp.add_pixels4;
13361342 for(i=16; i<16+8; i++){
1337− if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h, h->mb, i*16,pixel_shift))
1338− idct_add (dest[(i&4)>>2] + block_offset[i], h->mb + (i*16<<pixel_shift), uvlinesize);
1343+ if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16))
1344+ idct_add (dest[(i&4)>>2] + block_offset[i], h->mb + (i*16 << pixel_shift), uvlinesize);
13391345 }
13401346 }
13411347 }else{
13421348 if(is_h264){
13431349 if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ])
1344− h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16<<pixel_shift) , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
1350+ h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16 << pixel_shift) , h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
13451351 if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ])
1346− h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + ((16*16+4*16)<<pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
1352+ h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + ((16*16+4*16) << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
13471353 h->h264dsp.h264_idct_add8(dest, block_offset,
13481354 h->mb, uvlinesize,
13491355 h->non_zero_count_cache);
@@ -1370,9 +1376,12 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 20 unmodified lines
13701376 /**
13711377 * Process a macroblock; this case avoids checks for expensive uncommon cases.
13721378 */
1373−static void hl_decode_mb_simple8(H264Context *h){
1374− hl_decode_mb_internal(h, 1, 0);
1379+#define hl_decode_mb_simple(sh, bits) \
1380+static void hl_decode_mb_simple_ ## bits(H264Context *h){ \
1381+ hl_decode_mb_internal(h, 1, sh); \
13751382 }
1383+hl_decode_mb_simple(0, 8);
1384+hl_decode_mb_simple(1, 16);
13761385
13771386 /**
13781387 * Process a macroblock; this handles edge cases, such as interlacing.
@@ -1387,11 +1396,12 @@ void ff_h264_hl_decode_mb(H264Context *h){ · 8 unmodified lines
13871396 const int mb_type= s->current_picture.mb_type[mb_xy];
13881397 int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;
13891398
1390− if (is_complex || h->pixel_shift)
1399+ if (is_complex) {
13911400 hl_decode_mb_complex(h);
1392− else{
1393− hl_decode_mb_simple8(h);
1394− }
1401+ } else if (h->pixel_shift) {
1402+ hl_decode_mb_simple_16(h);
1403+ } else
1404+ hl_decode_mb_simple_8(h);
13951405 }
13961406
13971407 static int pred_weight_table(H264Context *h){
@@ -2557,6 +2567,7 @@ static void loop_filter(H264Context *h){ · 1159 unmodified lines
25572567 const int end_mb_y= s->mb_y + FRAME_MBAFF;
25582568 const int old_slice_type= h->slice_type;
25592569 const int end_mb_x = s->mb_x;
2570+ const int pixel_shift = h->pixel_shift;
25602571
25612572 if(h->deblocking_filter) {
25622573 int start_x= s->resync_mb_y == s->mb_y ? s->resync_mb_x : 0;
@@ -2573,9 +2584,9 @@ static void loop_filter(H264Context *h){ · 10 unmodified lines
25732584
25742585 s->mb_x= mb_x;
25752586 s->mb_y= mb_y;
2576− dest_y = s->current_picture.data[0] + ((mb_x<<h->pixel_shift) + mb_y * s->linesize ) * 16;
2577− dest_cb = s->current_picture.data[1] + ((mb_x<<h->pixel_shift) + mb_y * s->uvlinesize) * 8;
2578− dest_cr = s->current_picture.data[2] + ((mb_x<<h->pixel_shift) + mb_y * s->uvlinesize) * 8;
2587+ dest_y = s->current_picture.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16;
2588+ dest_cb = s->current_picture.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
2589+ dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
25792590 //FIXME simplify above
25802591
25812592 if (MB_FIELD) {
@@ -3060,7 +3071,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ · 478 unmodified lines
30603071 if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
30613072 if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
30623073 avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
3063− h->pixel_shift = h->sps.bit_depth_luma/9;
3074+ h->pixel_shift = h->sps.bit_depth_luma > 8;
30643075
30653076 ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
30663077 ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
libavcodec/h264.h+5−5
@@ -108,7 +108,7 @@ · 107 unmodified lines
108108 */
109109 #define DELAYED_PIC_REF 4
110110
111−#define QP_MAX_MAX (51 + 2*6) // The maximum supported qp
111+#define QP_MAX_NUM (51 + 2*6) // The maximum supported qp
112112
113113 /* NAL unit types */
114114 enum {
@@ -266,7 +266,7 @@ typedef struct MMCO{ · 151 unmodified lines
266266 typedef struct H264Context{
267267 MpegEncContext s;
268268 H264DSPContext h264dsp;
269− int pixel_shift;
269+ int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
270270 int chroma_qp[2]; //QPc
271271
272272 int qp_thresh; ///< QP threshold to skip loopfilter
@@ -355,8 +355,8 @@ typedef struct H264Context{ · 82 unmodified lines
355355 */
356356 PPS pps; //FIXME move to Picture perhaps? (->no) do we need that?
357357
358− uint32_t dequant4_buffer[6][QP_MAX_MAX+1][16]; //FIXME should these be moved down?
359− uint32_t dequant8_buffer[2][QP_MAX_MAX+1][64];
358+ uint32_t dequant4_buffer[6][QP_MAX_NUM+1][16]; //FIXME should these be moved down?
359+ uint32_t dequant8_buffer[2][QP_MAX_NUM+1][64];
360360 uint32_t (*dequant4_coeff[6])[16];
361361 uint32_t (*dequant8_coeff[2])[64];
362362
@@ -597,7 +597,7 @@ typedef struct H264Context{ · 234 unmodified lines
597597 }H264Context;
598598
599599
600−extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_MAX+1]; ///< One chroma qp table for each supported bit depth (8, 9, 10).
600+extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM+1]; ///< One chroma qp table for each supported bit depth (8, 9, 10).
601601
602602 /**
603603 * Decode SEI
libavcodec/h264_cabac.c+14−12
@@ -1103,10 +1103,11 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 1102 unmodified lines
11031103
11041104
11051105 #define STORE_BLOCK(type) \
1106− do {\
1107− uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base;\
1108−\
1109− int j= scantable[index[--coeff_count]];\
1106+ do { \
1107+ uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base; \
1108+ \
1109+ int j= scantable[index[--coeff_count]]; \
1110+ \
11101111 if( get_cabac( CC, ctx ) == 0 ) { \
11111112 node_ctx = coeff_abs_level_transition[0][node_ctx]; \
11121113 if( is_dc ) { \
@@ -1141,8 +1142,8 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 28 unmodified lines
11411142 }else{ \
11421143 ((type*)block)[j] = ((int)(get_cabac_bypass_sign( CC, -coeff_abs ) * qmul[j] + 32)) >> 6; \
11431144 } \
1144− }\
1145− } while( coeff_count );
1145+ } \
1146+ } while ( coeff_count );
11461147
11471148 if (h->pixel_shift) {
11481149 STORE_BLOCK(int32_t)
@@ -1204,6 +1205,7 @@ int ff_h264_decode_mb_cabac(H264Context *h) { · 55 unmodified lines
12041205 int mb_xy;
12051206 int mb_type, partition_count, cbp = 0;
12061207 int dct8x8_allowed= h->pps.transform_8x8_mode;
1208+ const int pixel_shift = h->pixel_shift;
12071209
12081210 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
12091211
@@ -1312,7 +1314,7 @@ decode_intra_mb: · 102 unmodified lines
13121314 h->slice_table[ mb_xy ]= h->slice_num;
13131315
13141316 if(IS_INTRA_PCM(mb_type)) {
1315− const int mb_size = 384*h->sps.bit_depth_luma/8;
1317+ const int mb_size = (384*h->sps.bit_depth_luma) >> 3;
13161318 const uint8_t *ptr;
13171319
13181320 // We assume these blocks are very rare so we do not optimize it.
@@ -1670,7 +1672,7 @@ decode_intra_mb: · 351 unmodified lines
16701672 qmul = h->dequant4_coeff[0][s->qscale];
16711673 for( i = 0; i < 16; i++ ) {
16721674 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i );
1673− decode_cabac_residual_nondc(h, h->mb + (16*i<<h->pixel_shift), 1, i, scan + 1, qmul, 15);
1675+ decode_cabac_residual_nondc(h, h->mb + (16*i << pixel_shift), 1, i, scan + 1, qmul, 15);
16741676 }
16751677 } else {
16761678 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
@@ -1680,7 +1682,7 @@ decode_intra_mb: · 3 unmodified lines
16801682 for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
16811683 if( cbp & (1<<i8x8) ) {
16821684 if( IS_8x8DCT(mb_type) ) {
1683− decode_cabac_residual_nondc(h, h->mb + (64*i8x8<<h->pixel_shift), 5, 4*i8x8,
1685+ decode_cabac_residual_nondc(h, h->mb + (64*i8x8 << pixel_shift), 5, 4*i8x8,
16841686 scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64);
16851687 } else {
16861688 qmul = h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale];
@@ -1688,7 +1690,7 @@ decode_intra_mb: · 1 unmodified line
16881690 const int index = 4*i8x8 + i4x4;
16891691 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );
16901692 //START_TIMER
1691− decode_cabac_residual_nondc(h, h->mb + (16*index<<h->pixel_shift), 2, index, scan, qmul, 16);
1693+ decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 2, index, scan, qmul, 16);
16921694 //STOP_TIMER("decode_residual")
16931695 }
16941696 }
@@ -1703,7 +1705,7 @@ decode_intra_mb: · 8 unmodified lines
17031705 int c;
17041706 for( c = 0; c < 2; c++ ) {
17051707 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
1706− decode_cabac_residual_dc(h, h->mb + ((256 + 16*4*c)<<h->pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
1708+ decode_cabac_residual_dc(h, h->mb + ((256 + 16*4*c) << pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
17071709 }
17081710 }
17091711
@@ -1714,7 +1716,7 @@ decode_intra_mb: · 4 unmodified lines
17141716 for( i = 0; i < 4; i++ ) {
17151717 const int index = 16 + 4 * c + i;
17161718 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 );
1717− decode_cabac_residual_nondc(h, h->mb + (16*index<<h->pixel_shift), 4, index, scan + 1, qmul, 15);
1719+ decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 4, index, scan + 1, qmul, 15);
17181720 }
17191721 }
17201722 } else {
libavcodec/h264_cavlc.c+6−5
@@ -542,6 +542,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h){ · 541 unmodified lines
542542 int partition_count;
543543 unsigned int mb_type, cbp;
544544 int dct8x8_allowed= h->pps.transform_8x8_mode;
545+ const int pixel_shift = h->pixel_shift;
545546
546547 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
547548
@@ -961,7 +962,7 @@ decode_intra_mb: · 413 unmodified lines
961962 for(i8x8=0; i8x8<4; i8x8++){
962963 for(i4x4=0; i4x4<4; i4x4++){
963964 const int index= i4x4 + 4*i8x8;
964− if( decode_residual(h, h->intra_gb_ptr, h->mb + (16*index<<h->pixel_shift), index, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 ){
965+ if( decode_residual(h, h->intra_gb_ptr, h->mb + (16*index << pixel_shift), index, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 ){
965966 return -1;
966967 }
967968 }
@@ -973,7 +974,7 @@ decode_intra_mb: · 5 unmodified lines
973974 for(i8x8=0; i8x8<4; i8x8++){
974975 if(cbp & (1<<i8x8)){
975976 if(IS_8x8DCT(mb_type)){
976− DCTELEM *buf = &h->mb[64*i8x8<<h->pixel_shift];
977+ DCTELEM *buf = &h->mb[64*i8x8 << pixel_shift];
977978 uint8_t *nnz;
978979 for(i4x4=0; i4x4<4; i4x4++){
979980 if( decode_residual(h, gb, buf, i4x4+4*i8x8, scan8x8+16*i4x4,
@@ -986,7 +987,7 @@ decode_intra_mb: · 6 unmodified lines
986987 for(i4x4=0; i4x4<4; i4x4++){
987988 const int index= i4x4 + 4*i8x8;
988989
989− if( decode_residual(h, gb, h->mb + (16*index<<h->pixel_shift), index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) <0 ){
990+ if( decode_residual(h, gb, h->mb + (16*index << pixel_shift), index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) <0 ){
990991 return -1;
991992 }
992993 }
@@ -1000,7 +1001,7 @@ decode_intra_mb: · 7 unmodified lines
10001001
10011002 if(cbp&0x30){
10021003 for(chroma_idx=0; chroma_idx<2; chroma_idx++)
1003− if( decode_residual(h, gb, h->mb + ((256 + 16*4*chroma_idx)<<h->pixel_shift), CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){
1004+ if( decode_residual(h, gb, h->mb + ((256 + 16*4*chroma_idx) << pixel_shift), CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){
10041005 return -1;
10051006 }
10061007 }
@@ -1010,7 +1011,7 @@ decode_intra_mb: · 3 unmodified lines
10101011 const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]];
10111012 for(i4x4=0; i4x4<4; i4x4++){
10121013 const int index= 16 + 4*chroma_idx + i4x4;
1013− if( decode_residual(h, gb, h->mb + (16*index<<h->pixel_shift), index, scan + 1, qmul, 15) < 0){
1014+ if( decode_residual(h, gb, h->mb + (16*index << pixel_shift), index, scan + 1, qmul, 15) < 0){
10141015 return -1;
10151016 }
10161017 }
libavcodec/h264_loopfilter.c+59−165
@@ -101,197 +101,92 @@ static const uint8_t tc0_table[52*3][4] = { · 100 unmodified lines
101101 };
102102
103103 static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h) {
104− const int bit_depth = h->sps.bit_depth_luma;
105− const int qp_bd_offset = 6*(bit_depth-8);
104+ const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
106105 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
107− const int alpha = alpha_table[index_a] << (bit_depth-8);
108− const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);
106+ const int alpha = alpha_table[index_a];
107+ const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
109108 if (alpha ==0 || beta == 0) return;
110109
111110 if( bS[0] < 4 ) {
112111 int8_t tc[4];
113− tc[0] = tc0_table[index_a][bS[0]] << (bit_depth-8);
114− tc[1] = tc0_table[index_a][bS[1]] << (bit_depth-8);
115− tc[2] = tc0_table[index_a][bS[2]] << (bit_depth-8);
116− tc[3] = tc0_table[index_a][bS[3]] << (bit_depth-8);
112+ tc[0] = tc0_table[index_a][bS[0]];
113+ tc[1] = tc0_table[index_a][bS[1]];
114+ tc[2] = tc0_table[index_a][bS[2]];
115+ tc[3] = tc0_table[index_a][bS[3]];
117116 h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc);
118117 } else {
119118 h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);
120119 }
121120 }
122121 static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
123− const int bit_depth = h->sps.bit_depth_luma;
124− const int qp_bd_offset = 6*(bit_depth-8);
122+ const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
125123 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
126− const int alpha = alpha_table[index_a] << (bit_depth-8);
127− const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);
124+ const int alpha = alpha_table[index_a];
125+ const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
128126 if (alpha ==0 || beta == 0) return;
129127
130128 if( bS[0] < 4 ) {
131129 int8_t tc[4];
132− tc[0] = (tc0_table[index_a][bS[0]] << (bit_depth-8))+1;
133− tc[1] = (tc0_table[index_a][bS[1]] << (bit_depth-8))+1;
134− tc[2] = (tc0_table[index_a][bS[2]] << (bit_depth-8))+1;
135− tc[3] = (tc0_table[index_a][bS[3]] << (bit_depth-8))+1;
130+ tc[0] = tc0_table[index_a][bS[0]]+1;
131+ tc[1] = tc0_table[index_a][bS[1]]+1;
132+ tc[2] = tc0_table[index_a][bS[2]]+1;
133+ tc[3] = tc0_table[index_a][bS[3]]+1;
136134 h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
137135 } else {
138136 h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
139137 }
140138 }
141139
142−static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) {
143− int i;
144− const int bit_depth = h->sps.bit_depth_luma;
145− const int qp_bd_offset = 6*(bit_depth-8);
140+static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) {
141+ const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
146142 int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
147− int alpha = alpha_table[index_a] << (bit_depth-8);
148− int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);
149− for( i = 0; i < 8; i++, pix += stride) {
150− const int bS_index = (i >> 1) * bsi;
151−
152− if( bS[bS_index] == 0 ) {
153− continue;
154− }
155−
156− if( bS[bS_index] < 4 ) {
157− const int tc0 = tc0_table[index_a][bS[bS_index]] << (bit_depth-8);
158− const int p0 = pix[-1];
159− const int p1 = pix[-2];
160− const int p2 = pix[-3];
161− const int q0 = pix[0];
162− const int q1 = pix[1];
163− const int q2 = pix[2];
164−
165− if( FFABS( p0 - q0 ) < alpha &&
166− FFABS( p1 - p0 ) < beta &&
167− FFABS( q1 - q0 ) < beta ) {
168− int tc = tc0;
169− int i_delta;
170−
171− if( FFABS( p2 - p0 ) < beta ) {
172− if(tc0)
173− pix[-2] = p1 + av_clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 );
174− tc++;
175− }
176− if( FFABS( q2 - q0 ) < beta ) {
177− if(tc0)
178− pix[1] = q1 + av_clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 );
179− tc++;
180− }
181−
182− i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
183− pix[-1] = av_clip_uint8( p0 + i_delta ); /* p0' */
184− pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */
185− tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
186− }
187− }else{
188− const int p0 = pix[-1];
189− const int p1 = pix[-2];
190− const int p2 = pix[-3];
191−
192− const int q0 = pix[0];
193− const int q1 = pix[1];
194− const int q2 = pix[2];
195−
196− if( FFABS( p0 - q0 ) < alpha &&
197− FFABS( p1 - p0 ) < beta &&
198− FFABS( q1 - q0 ) < beta ) {
143+ int alpha = alpha_table[index_a];
144+ int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
145+ if (alpha ==0 || beta == 0) return;
199146
200− if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
201− if( FFABS( p2 - p0 ) < beta)
202− {
203− const int p3 = pix[-4];
204− /* p0', p1', p2' */
205− pix[-1] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
206− pix[-2] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
207− pix[-3] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
208− } else {
209− /* p0' */
210− pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
211− }
212− if( FFABS( q2 - q0 ) < beta)
213− {
214− const int q3 = pix[3];
215− /* q0', q1', q2' */
216− pix[0] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
217− pix[1] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
218− pix[2] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
219− } else {
220− /* q0' */
221− pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
222− }
223− }else{
224− /* p0', q0' */
225− pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
226− pix[ 0] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
227− }
228− tprintf(h->s.avctx, "filter_mb_mbaff_edgev i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, p2, p1, p0, q0, q1, q2, pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
229− }
230− }
147+ if( bS[0] < 4 ) {
148+ int8_t tc[4];
149+ tc[0] = tc0_table[index_a][bS[0*bsi]];
150+ tc[1] = tc0_table[index_a][bS[1*bsi]];
151+ tc[2] = tc0_table[index_a][bS[2*bsi]];
152+ tc[3] = tc0_table[index_a][bS[3*bsi]];
153+ h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
154+ } else {
155+ h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
231156 }
232157 }
233−static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) {
234− int i;
235− const int bit_depth = h->sps.bit_depth_luma;
236− const int qp_bd_offset = 6*(bit_depth-8);
158+static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) {
159+ const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
237160 int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
238− int alpha = alpha_table[index_a] << (bit_depth-8);
239− int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);
240− for( i = 0; i < 4; i++, pix += stride) {
241− const int bS_index = i*bsi;
242−
243− if( bS[bS_index] == 0 ) {
244− continue;
245− }
161+ int alpha = alpha_table[index_a];
162+ int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
163+ if (alpha ==0 || beta == 0) return;
246164
247− if( bS[bS_index] < 4 ) {
248− const int tc = (tc0_table[index_a][bS[bS_index]] << (bit_depth-8)) + 1;
249− const int p0 = pix[-1];
250− const int p1 = pix[-2];
251− const int q0 = pix[0];
252− const int q1 = pix[1];
253−
254− if( FFABS( p0 - q0 ) < alpha &&
255− FFABS( p1 - p0 ) < beta &&
256− FFABS( q1 - q0 ) < beta ) {
257− const int i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
258−
259− pix[-1] = av_clip_uint8( p0 + i_delta ); /* p0' */
260− pix[0] = av_clip_uint8( q0 - i_delta ); /* q0' */
261− tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, qp[qp_index], index_a, alpha, beta, tc, bS[bS_index], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1);
262− }
263− }else{
264− const int p0 = pix[-1];
265− const int p1 = pix[-2];
266− const int q0 = pix[0];
267− const int q1 = pix[1];
268−
269− if( FFABS( p0 - q0 ) < alpha &&
270− FFABS( p1 - p0 ) < beta &&
271− FFABS( q1 - q0 ) < beta ) {
272−
273− pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
274− pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
275− tprintf(h->s.avctx, "filter_mb_mbaff_edgecv i:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x, %02x, %02x]\n", i, pix[-3], p1, p0, q0, q1, pix[2], pix[-3], pix[-2], pix[-1], pix[0], pix[1], pix[2]);
276− }
277− }
165+ if( bS[0] < 4 ) {
166+ int8_t tc[4];
167+ tc[0] = tc0_table[index_a][bS[0*bsi]] + 1;
168+ tc[1] = tc0_table[index_a][bS[1*bsi]] + 1;
169+ tc[2] = tc0_table[index_a][bS[2*bsi]] + 1;
170+ tc[3] = tc0_table[index_a][bS[3*bsi]] + 1;
171+ h->h264dsp.h264_h_loop_filter_chroma_mbaff(pix, stride, alpha, beta, tc);
172+ } else {
173+ h->h264dsp.h264_h_loop_filter_chroma_mbaff_intra(pix, stride, alpha, beta);
278174 }
279175 }
280176
281177 static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
282− const int bit_depth = h->sps.bit_depth_luma;
283− const int qp_bd_offset = 6*(bit_depth-8);
178+ const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
284179 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
285− const int alpha = alpha_table[index_a] << (bit_depth-8);
286− const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);
180+ const int alpha = alpha_table[index_a];
181+ const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
287182 if (alpha ==0 || beta == 0) return;
288183
289184 if( bS[0] < 4 ) {
290185 int8_t tc[4];
291− tc[0] = tc0_table[index_a][bS[0]] << (bit_depth-8);
292− tc[1] = tc0_table[index_a][bS[1]] << (bit_depth-8);
293− tc[2] = tc0_table[index_a][bS[2]] << (bit_depth-8);
294− tc[3] = tc0_table[index_a][bS[3]] << (bit_depth-8);
186+ tc[0] = tc0_table[index_a][bS[0]];
187+ tc[1] = tc0_table[index_a][bS[1]];
188+ tc[2] = tc0_table[index_a][bS[2]];
189+ tc[3] = tc0_table[index_a][bS[3]];
295190 h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
296191 } else {
297192 h->h264dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);
@@ -299,19 +194,18 @@ static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t · 1 unmodified line
299194 }
300195
301196 static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {
302− const int bit_depth = h->sps.bit_depth_luma;
303− const int qp_bd_offset = 6*(bit_depth-8);
197+ const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
304198 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
305− const int alpha = alpha_table[index_a] << (bit_depth-8);
306− const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);
199+ const int alpha = alpha_table[index_a];
200+ const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
307201 if (alpha ==0 || beta == 0) return;
308202
309203 if( bS[0] < 4 ) {
310204 int8_t tc[4];
311− tc[0] = (tc0_table[index_a][bS[0]] << (bit_depth-8))+1;
312− tc[1] = (tc0_table[index_a][bS[1]] << (bit_depth-8))+1;
313− tc[2] = (tc0_table[index_a][bS[2]] << (bit_depth-8))+1;
314− tc[3] = (tc0_table[index_a][bS[3]] << (bit_depth-8))+1;
205+ tc[0] = tc0_table[index_a][bS[0]]+1;
206+ tc[1] = tc0_table[index_a][bS[1]]+1;
207+ tc[2] = tc0_table[index_a][bS[2]]+1;
208+ tc[3] = tc0_table[index_a][bS[3]]+1;
315209 h->h264dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
316210 } else {
317211 h->h264dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
@@ -650,10 +544,10 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u · 332 unmodified lines
650544 tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
651545 //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
652546 if( dir == 0 ) {
653− filter_mb_edgev( &img_y[4*edge<<h->pixel_shift], linesize, bS, qp, h );
547+ filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, h );
654548 if( (edge&1) == 0 ) {
655− filter_mb_edgecv( &img_cb[2*edge<<h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h);
656− filter_mb_edgecv( &img_cr[2*edge<<h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h);
549+ filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h);
550+ filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h);
657551 }
658552 } else {
659553 filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, h );
libavcodec/h264_ps.c+1−1
@@ -70,7 +70,7 @@ static const AVRational pixel_aspect[17]={ · 69 unmodified lines
7070 QP(37,d), QP(37,d), QP(37,d), QP(38,d), QP(38,d), QP(38,d),\
7171 QP(39,d), QP(39,d), QP(39,d), QP(39,d)
7272
73−const uint8_t ff_h264_chroma_qp[3][QP_MAX_MAX+1] = {
73+const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM+1] = {
7474 {
7575 CHROMA_QP_TABLE_END(8)
7676 },
libavcodec/h264_refs.c+3−2
@@ -629,8 +629,9 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ · 628 unmodified lines
629629 * short_ref and long_ref buffers.
630630 */
631631 av_log(h->s.avctx, AV_LOG_ERROR,
632− "number of reference frames exceeds max (probably "
633− "corrupt input), discarding one long:%d short:%d max:%d\n", h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
632+ "number of reference frames (%d+%d) exceeds max (%d; probably "
633+ "corrupt input), discarding one\n",
634+ h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
634635
635636 if (h->long_ref_count && !h->short_ref_count) {
636637 for (i = 0; i < 16; ++i)
libavcodec/h264dsp.c+54−50
@@ -30,15 +30,15 @@ · 29 unmodified lines
3030 #include "h264dsp.h"
3131
3232 #define BIT_DEPTH 8
33−#include "h264dsp_internal.h"
33+#include "h264dsp_template.c"
3434 #undef BIT_DEPTH
3535
3636 #define BIT_DEPTH 9
37−#include "h264dsp_internal.h"
37+#include "h264dsp_template.c"
3838 #undef BIT_DEPTH
3939
4040 #define BIT_DEPTH 10
41−#include "h264dsp_internal.h"
41+#include "h264dsp_template.c"
4242 #undef BIT_DEPTH
4343
4444 void ff_h264dsp_init(H264DSPContext *c, const int bit_depth)
@@ -47,58 +47,62 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) · 2 unmodified lines
4747 #define FUNC(a, depth) a ## _ ## depth ## _c
4848
4949 #define H264_DSP(depth) \
50− c->h264_idct_add = FUNC(ff_h264_idct_add , depth);\
51− c->h264_idct8_add = FUNC(ff_h264_idct8_add , depth);\
52− c->h264_idct_dc_add = FUNC(ff_h264_idct_dc_add , depth);\
53− c->h264_idct8_dc_add = FUNC(ff_h264_idct8_dc_add , depth);\
54− c->h264_idct_add16 = FUNC(ff_h264_idct_add16 , depth);\
55− c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4 , depth);\
56− c->h264_idct_add8 = FUNC(ff_h264_idct_add8 , depth);\
57− c->h264_idct_add16intra = FUNC(ff_h264_idct_add16intra , depth);\
58− c->h264_luma_dc_dequant_idct = FUNC(ff_h264_luma_dc_dequant_idct , depth);\
59− c->h264_chroma_dc_dequant_idct = FUNC(ff_h264_chroma_dc_dequant_idct , depth);\
50+ c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
51+ c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\
52+ c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, depth);\
53+ c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
54+ c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
55+ c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
56+ c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
57+ c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
58+ c->h264_luma_dc_dequant_idct= FUNC(ff_h264_luma_dc_dequant_idct, depth);\
59+ c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
6060 \
61− c->weight_h264_pixels_tab[0] = FUNC( weight_h264_pixels16x16 , depth);\
62− c->weight_h264_pixels_tab[1] = FUNC( weight_h264_pixels16x8 , depth);\
63− c->weight_h264_pixels_tab[2] = FUNC( weight_h264_pixels8x16 , depth);\
64− c->weight_h264_pixels_tab[3] = FUNC( weight_h264_pixels8x8 , depth);\
65− c->weight_h264_pixels_tab[4] = FUNC( weight_h264_pixels8x4 , depth);\
66− c->weight_h264_pixels_tab[5] = FUNC( weight_h264_pixels4x8 , depth);\
67− c->weight_h264_pixels_tab[6] = FUNC( weight_h264_pixels4x4 , depth);\
68− c->weight_h264_pixels_tab[7] = FUNC( weight_h264_pixels4x2 , depth);\
69− c->weight_h264_pixels_tab[8] = FUNC( weight_h264_pixels2x4 , depth);\
70− c->weight_h264_pixels_tab[9] = FUNC( weight_h264_pixels2x2 , depth);\
71− c->biweight_h264_pixels_tab[0] = FUNC(biweight_h264_pixels16x16 , depth);\
72− c->biweight_h264_pixels_tab[1] = FUNC(biweight_h264_pixels16x8 , depth);\
73− c->biweight_h264_pixels_tab[2] = FUNC(biweight_h264_pixels8x16 , depth);\
74− c->biweight_h264_pixels_tab[3] = FUNC(biweight_h264_pixels8x8 , depth);\
75− c->biweight_h264_pixels_tab[4] = FUNC(biweight_h264_pixels8x4 , depth);\
76− c->biweight_h264_pixels_tab[5] = FUNC(biweight_h264_pixels4x8 , depth);\
77− c->biweight_h264_pixels_tab[6] = FUNC(biweight_h264_pixels4x4 , depth);\
78− c->biweight_h264_pixels_tab[7] = FUNC(biweight_h264_pixels4x2 , depth);\
79− c->biweight_h264_pixels_tab[8] = FUNC(biweight_h264_pixels2x4 , depth);\
80− c->biweight_h264_pixels_tab[9] = FUNC(biweight_h264_pixels2x2 , depth);\
61+ c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16x16, depth);\
62+ c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels16x8, depth);\
63+ c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels8x16, depth);\
64+ c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels8x8, depth);\
65+ c->weight_h264_pixels_tab[4]= FUNC(weight_h264_pixels8x4, depth);\
66+ c->weight_h264_pixels_tab[5]= FUNC(weight_h264_pixels4x8, depth);\
67+ c->weight_h264_pixels_tab[6]= FUNC(weight_h264_pixels4x4, depth);\
68+ c->weight_h264_pixels_tab[7]= FUNC(weight_h264_pixels4x2, depth);\
69+ c->weight_h264_pixels_tab[8]= FUNC(weight_h264_pixels2x4, depth);\
70+ c->weight_h264_pixels_tab[9]= FUNC(weight_h264_pixels2x2, depth);\
71+ c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16x16, depth);\
72+ c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels16x8, depth);\
73+ c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels8x16, depth);\
74+ c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels8x8, depth);\
75+ c->biweight_h264_pixels_tab[4]= FUNC(biweight_h264_pixels8x4, depth);\
76+ c->biweight_h264_pixels_tab[5]= FUNC(biweight_h264_pixels4x8, depth);\
77+ c->biweight_h264_pixels_tab[6]= FUNC(biweight_h264_pixels4x4, depth);\
78+ c->biweight_h264_pixels_tab[7]= FUNC(biweight_h264_pixels4x2, depth);\
79+ c->biweight_h264_pixels_tab[8]= FUNC(biweight_h264_pixels2x4, depth);\
80+ c->biweight_h264_pixels_tab[9]= FUNC(biweight_h264_pixels2x2, depth);\
8181 \
82− c->h264_v_loop_filter_luma = FUNC(h264_v_loop_filter_luma , depth);\
83− c->h264_h_loop_filter_luma = FUNC(h264_h_loop_filter_luma , depth);\
84− c->h264_v_loop_filter_luma_intra = FUNC(h264_v_loop_filter_luma_intra , depth);\
85− c->h264_h_loop_filter_luma_intra = FUNC(h264_h_loop_filter_luma_intra , depth);\
86− c->h264_v_loop_filter_chroma = FUNC(h264_v_loop_filter_chroma , depth);\
87− c->h264_h_loop_filter_chroma = FUNC(h264_h_loop_filter_chroma , depth);\
88− c->h264_v_loop_filter_chroma_intra = FUNC(h264_v_loop_filter_chroma_intra, depth);\
89− c->h264_h_loop_filter_chroma_intra = FUNC(h264_h_loop_filter_chroma_intra, depth);\
82+ c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\
83+ c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\
84+ c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
85+ c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\
86+ c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
87+ c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
88+ c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
89+ c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
90+ c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
91+ c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
92+ c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
93+ c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
9094 c->h264_loop_filter_strength= NULL;
9195
9296 switch (bit_depth) {
93− case 9:
94− H264_DSP(9);
95− break;
96− case 10:
97− H264_DSP(10);
98− break;
99− default:
100− H264_DSP(8);
101− break;
97+ case 9:
98+ H264_DSP(9);
99+ break;
100+ case 10:
101+ H264_DSP(10);
102+ break;
103+ default:
104+ H264_DSP(8);
105+ break;
102106 }
103107
104108 if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth);
libavcodec/h264dsp.h+4−0
@@ -45,13 +45,17 @@ typedef struct H264DSPContext{ · 44 unmodified lines
4545 /* loop filter */
4646 void (*h264_v_loop_filter_luma)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0);
4747 void (*h264_h_loop_filter_luma)(uint8_t *pix/*align 4 */, int stride, int alpha, int beta, int8_t *tc0);
48+ void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0);
4849 /* v/h_loop_filter_luma_intra: align 16 */
4950 void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta);
5051 void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta);
52+ void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta);
5153 void (*h264_v_loop_filter_chroma)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0);
5254 void (*h264_h_loop_filter_chroma)(uint8_t *pix/*align 4*/, int stride, int alpha, int beta, int8_t *tc0);
55+ void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0);
5356 void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);
5457 void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);
58+ void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);
5559 // h264_loop_filter_strength: simd only. the C version is inlined in h264.c
5660 void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], int8_t ref[2][40], int16_t mv[2][40][2],
5761 int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field);
libavcodec/h264dsp_template.c+313−0
@@ -0,0 +1,313 @@
1+/*
2+ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3+ * Copyright (c) 2003-2010 Michael Niedermayer <michaelni@gmx.at>
4+ *
5+ * This file is part of Libav.
6+ *
7+ * Libav is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Lesser General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2.1 of the License, or (at your option) any later version.
11+ *
12+ * Libav is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with Libav; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ */
21+
22+/**
23+ * @file
24+ * H.264 / AVC / MPEG4 part10 DSP functions.
25+ * @author Michael Niedermayer <michaelni@gmx.at>
26+ */
27+
28+#include "high_bit_depth.h"
29+
30+#define op_scale1(x) block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom )
31+#define op_scale2(x) dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
32+#define H264_WEIGHT(W,H) \
33+static void FUNCC(weight_h264_pixels ## W ## x ## H)(uint8_t *_block, int stride, int log2_denom, int weight, int offset){ \
34+ int y; \
35+ pixel *block = (pixel*)_block; \
36+ stride /= sizeof(pixel); \
37+ offset <<= (log2_denom + (BIT_DEPTH-8)); \
38+ if(log2_denom) offset += 1<<(log2_denom-1); \
39+ for(y=0; y<H; y++, block += stride){ \
40+ op_scale1(0); \
41+ op_scale1(1); \
42+ if(W==2) continue; \
43+ op_scale1(2); \
44+ op_scale1(3); \
45+ if(W==4) continue; \
46+ op_scale1(4); \
47+ op_scale1(5); \
48+ op_scale1(6); \
49+ op_scale1(7); \
50+ if(W==8) continue; \
51+ op_scale1(8); \
52+ op_scale1(9); \
53+ op_scale1(10); \
54+ op_scale1(11); \
55+ op_scale1(12); \
56+ op_scale1(13); \
57+ op_scale1(14); \
58+ op_scale1(15); \
59+ } \
60+} \
61+static void FUNCC(biweight_h264_pixels ## W ## x ## H)(uint8_t *_dst, uint8_t *_src, int stride, int log2_denom, int weightd, int weights, int offset){ \
62+ int y; \
63+ pixel *dst = (pixel*)_dst; \
64+ pixel *src = (pixel*)_src; \
65+ stride /= sizeof(pixel); \
66+ offset = ((offset + 1) | 1) << log2_denom; \
67+ for(y=0; y<H; y++, dst += stride, src += stride){ \
68+ op_scale2(0); \
69+ op_scale2(1); \
70+ if(W==2) continue; \
71+ op_scale2(2); \
72+ op_scale2(3); \
73+ if(W==4) continue; \
74+ op_scale2(4); \
75+ op_scale2(5); \
76+ op_scale2(6); \
77+ op_scale2(7); \
78+ if(W==8) continue; \
79+ op_scale2(8); \
80+ op_scale2(9); \
81+ op_scale2(10); \
82+ op_scale2(11); \
83+ op_scale2(12); \
84+ op_scale2(13); \
85+ op_scale2(14); \
86+ op_scale2(15); \
87+ } \
88+}
89+
90+H264_WEIGHT(16,16)
91+H264_WEIGHT(16,8)
92+H264_WEIGHT(8,16)
93+H264_WEIGHT(8,8)
94+H264_WEIGHT(8,4)
95+H264_WEIGHT(4,8)
96+H264_WEIGHT(4,4)
97+H264_WEIGHT(4,2)
98+H264_WEIGHT(2,4)
99+H264_WEIGHT(2,2)
100+
101+#undef op_scale1
102+#undef op_scale2
103+#undef H264_WEIGHT
104+
105+static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0)
106+{
107+ pixel *pix = (pixel*)_pix;
108+ int i, d;
109+ xstride /= sizeof(pixel);
110+ ystride /= sizeof(pixel);
111+ alpha <<= BIT_DEPTH - 8;
112+ beta <<= BIT_DEPTH - 8;
113+ for( i = 0; i < 4; i++ ) {
114+ const int tc_orig = tc0[i] << (BIT_DEPTH - 8);
115+ if( tc_orig < 0 ) {
116+ pix += inner_iters*ystride;
117+ continue;
118+ }
119+ for( d = 0; d < inner_iters; d++ ) {
120+ const int p0 = pix[-1*xstride];
121+ const int p1 = pix[-2*xstride];
122+ const int p2 = pix[-3*xstride];
123+ const int q0 = pix[0];
124+ const int q1 = pix[1*xstride];
125+ const int q2 = pix[2*xstride];
126+
127+ if( FFABS( p0 - q0 ) < alpha &&
128+ FFABS( p1 - p0 ) < beta &&
129+ FFABS( q1 - q0 ) < beta ) {
130+
131+ int tc = tc_orig;
132+ int i_delta;
133+
134+ if( FFABS( p2 - p0 ) < beta ) {
135+ if(tc_orig)
136+ pix[-2*xstride] = p1 + av_clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc_orig, tc_orig );
137+ tc++;
138+ }
139+ if( FFABS( q2 - q0 ) < beta ) {
140+ if(tc_orig)
141+ pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc_orig, tc_orig );
142+ tc++;
143+ }
144+
145+ i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
146+ pix[-xstride] = av_clip_pixel( p0 + i_delta ); /* p0' */
147+ pix[0] = av_clip_pixel( q0 - i_delta ); /* q0' */
148+ }
149+ pix += ystride;
150+ }
151+ }
152+}
153+static void FUNCC(h264_v_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
154+{
155+ FUNCC(h264_loop_filter_luma)(pix, stride, sizeof(pixel), 4, alpha, beta, tc0);
156+}
157+static void FUNCC(h264_h_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
158+{
159+ FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, 4, alpha, beta, tc0);
160+}
161+static void FUNCC(h264_h_loop_filter_luma_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
162+{
163+ FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, 2, alpha, beta, tc0);
164+}
165+
166+static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma_intra)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta)
167+{
168+ pixel *pix = (pixel*)_pix;
169+ int d;
170+ xstride /= sizeof(pixel);
171+ ystride /= sizeof(pixel);
172+ alpha <<= BIT_DEPTH - 8;
173+ beta <<= BIT_DEPTH - 8;
174+ for( d = 0; d < 4 * inner_iters; d++ ) {
175+ const int p2 = pix[-3*xstride];
176+ const int p1 = pix[-2*xstride];
177+ const int p0 = pix[-1*xstride];
178+
179+ const int q0 = pix[ 0*xstride];
180+ const int q1 = pix[ 1*xstride];
181+ const int q2 = pix[ 2*xstride];
182+
183+ if( FFABS( p0 - q0 ) < alpha &&
184+ FFABS( p1 - p0 ) < beta &&
185+ FFABS( q1 - q0 ) < beta ) {
186+
187+ if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
188+ if( FFABS( p2 - p0 ) < beta)
189+ {
190+ const int p3 = pix[-4*xstride];
191+ /* p0', p1', p2' */
192+ pix[-1*xstride] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
193+ pix[-2*xstride] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
194+ pix[-3*xstride] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
195+ } else {
196+ /* p0' */
197+ pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
198+ }
199+ if( FFABS( q2 - q0 ) < beta)
200+ {
201+ const int q3 = pix[3*xstride];
202+ /* q0', q1', q2' */
203+ pix[0*xstride] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
204+ pix[1*xstride] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
205+ pix[2*xstride] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
206+ } else {
207+ /* q0' */
208+ pix[0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
209+ }
210+ }else{
211+ /* p0', q0' */
212+ pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
213+ pix[ 0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
214+ }
215+ }
216+ pix += ystride;
217+ }
218+}
219+static void FUNCC(h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta)
220+{
221+ FUNCC(h264_loop_filter_luma_intra)(pix, stride, sizeof(pixel), 4, alpha, beta);
222+}
223+static void FUNCC(h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta)
224+{
225+ FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), stride, 4, alpha, beta);
226+}
227+static void FUNCC(h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta)
228+{
229+ FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta);
230+}
231+
232+static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0)
233+{
234+ pixel *pix = (pixel*)_pix;
235+ int i, d;
236+ xstride /= sizeof(pixel);
237+ ystride /= sizeof(pixel);
238+ alpha <<= BIT_DEPTH - 8;
239+ beta <<= BIT_DEPTH - 8;
240+ for( i = 0; i < 4; i++ ) {
241+ const int tc = ((tc0[i] - 1) << (BIT_DEPTH - 8)) + 1;
242+ if( tc <= 0 ) {
243+ pix += inner_iters*ystride;
244+ continue;
245+ }
246+ for( d = 0; d < inner_iters; d++ ) {
247+ const int p0 = pix[-1*xstride];
248+ const int p1 = pix[-2*xstride];
249+ const int q0 = pix[0];
250+ const int q1 = pix[1*xstride];
251+
252+ if( FFABS( p0 - q0 ) < alpha &&
253+ FFABS( p1 - p0 ) < beta &&
254+ FFABS( q1 - q0 ) < beta ) {
255+
256+ int delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
257+
258+ pix[-xstride] = av_clip_pixel( p0 + delta ); /* p0' */
259+ pix[0] = av_clip_pixel( q0 - delta ); /* q0' */
260+ }
261+ pix += ystride;
262+ }
263+ }
264+}
265+static void FUNCC(h264_v_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
266+{
267+ FUNCC(h264_loop_filter_chroma)(pix, stride, sizeof(pixel), 2, alpha, beta, tc0);
268+}
269+static void FUNCC(h264_h_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
270+{
271+ FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 2, alpha, beta, tc0);
272+}
273+static void FUNCC(h264_h_loop_filter_chroma_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
274+{
275+ FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 1, alpha, beta, tc0);
276+}
277+
278+static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma_intra)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta)
279+{
280+ pixel *pix = (pixel*)_pix;
281+ int d;
282+ xstride /= sizeof(pixel);
283+ ystride /= sizeof(pixel);
284+ alpha <<= BIT_DEPTH - 8;
285+ beta <<= BIT_DEPTH - 8;
286+ for( d = 0; d < 4 * inner_iters; d++ ) {
287+ const int p0 = pix[-1*xstride];
288+ const int p1 = pix[-2*xstride];
289+ const int q0 = pix[0];
290+ const int q1 = pix[1*xstride];
291+
292+ if( FFABS( p0 - q0 ) < alpha &&
293+ FFABS( p1 - p0 ) < beta &&
294+ FFABS( q1 - q0 ) < beta ) {
295+
296+ pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
297+ pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
298+ }
299+ pix += ystride;
300+ }
301+}
302+static void FUNCC(h264_v_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta)
303+{
304+ FUNCC(h264_loop_filter_chroma_intra)(pix, stride, sizeof(pixel), 2, alpha, beta);
305+}
306+static void FUNCC(h264_h_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta)
307+{
308+ FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta);
309+}
310+static void FUNCC(h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta)
311+{
312+ FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 1, alpha, beta);
313+}
libavcodec/h264idct.c+3−3
@@ -26,13 +26,13 @@ · 25 unmodified lines
2626 */
2727
2828 #define BIT_DEPTH 8
29−#include "h264idct_internal.h"
29+#include "h264idct_template.c"
3030 #undef BIT_DEPTH
3131
3232 #define BIT_DEPTH 9
33−#include "h264idct_internal.h"
33+#include "h264idct_template.c"
3434 #undef BIT_DEPTH
3535
3636 #define BIT_DEPTH 10
37−#include "h264idct_internal.h"
37+#include "h264idct_template.c"
3838 #undef BIT_DEPTH
libavcodec/h264idct_template.c+291−0
@@ -0,0 +1,291 @@
1+/*
2+ * H.264 IDCT
3+ * Copyright (c) 2004-2011 Michael Niedermayer <michaelni@gmx.at>
4+ *
5+ * This file is part of Libav.
6+ *
7+ * Libav is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Lesser General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2.1 of the License, or (at your option) any later version.
11+ *
12+ * Libav is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with Libav; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ */
21+
22+/**
23+ * @file
24+ * H.264 IDCT.
25+ * @author Michael Niedermayer <michaelni@gmx.at>
26+ */
27+
28+#include "high_bit_depth.h"
29+
30+#ifndef AVCODEC_H264IDCT_INTERNAL_H
31+#define AVCODEC_H264IDCT_INTERNAL_H
32+//FIXME this table is a duplicate from h264data.h, and will be removed once the tables from, h264 have been split
33+static const uint8_t scan8[16 + 2*4]={
34+ 4+1*8, 5+1*8, 4+2*8, 5+2*8,
35+ 6+1*8, 7+1*8, 6+2*8, 7+2*8,
36+ 4+3*8, 5+3*8, 4+4*8, 5+4*8,
37+ 6+3*8, 7+3*8, 6+4*8, 7+4*8,
38+ 1+1*8, 2+1*8,
39+ 1+2*8, 2+2*8,
40+ 1+4*8, 2+4*8,
41+ 1+5*8, 2+5*8,
42+};
43+#endif
44+
45+static av_always_inline void FUNCC(idct_internal)(uint8_t *_dst, DCTELEM *_block, int stride, int block_stride, int shift, int add){
46+ int i;
47+ INIT_CLIP
48+ pixel *dst = (pixel*)_dst;
49+ dctcoef *block = (dctcoef*)_block;
50+ stride /= sizeof(pixel);
51+
52+ block[0] += 1<<(shift-1);
53+
54+ for(i=0; i<4; i++){
55+ const int z0= block[i + block_stride*0] + block[i + block_stride*2];
56+ const int z1= block[i + block_stride*0] - block[i + block_stride*2];
57+ const int z2= (block[i + block_stride*1]>>1) - block[i + block_stride*3];
58+ const int z3= block[i + block_stride*1] + (block[i + block_stride*3]>>1);
59+
60+ block[i + block_stride*0]= z0 + z3;
61+ block[i + block_stride*1]= z1 + z2;
62+ block[i + block_stride*2]= z1 - z2;
63+ block[i + block_stride*3]= z0 - z3;
64+ }
65+
66+ for(i=0; i<4; i++){
67+ const int z0= block[0 + block_stride*i] + block[2 + block_stride*i];
68+ const int z1= block[0 + block_stride*i] - block[2 + block_stride*i];
69+ const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i];
70+ const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1);
71+
72+ dst[i + 0*stride]= CLIP(add*dst[i + 0*stride] + ((z0 + z3) >> shift));
73+ dst[i + 1*stride]= CLIP(add*dst[i + 1*stride] + ((z1 + z2) >> shift));
74+ dst[i + 2*stride]= CLIP(add*dst[i + 2*stride] + ((z1 - z2) >> shift));
75+ dst[i + 3*stride]= CLIP(add*dst[i + 3*stride] + ((z0 - z3) >> shift));
76+ }
77+}
78+
79+void FUNCC(ff_h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride){
80+ FUNCC(idct_internal)(dst, block, stride, 4, 6, 1);
81+}
82+
83+void FUNCC(ff_h264_lowres_idct_add)(uint8_t *dst, int stride, DCTELEM *block){
84+ FUNCC(idct_internal)(dst, block, stride, 8, 3, 1);
85+}
86+
87+void FUNCC(ff_h264_lowres_idct_put)(uint8_t *dst, int stride, DCTELEM *block){
88+ FUNCC(idct_internal)(dst, block, stride, 8, 3, 0);
89+}
90+
91+void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, DCTELEM *_block, int stride){
92+ int i;
93+ INIT_CLIP
94+ pixel *dst = (pixel*)_dst;
95+ dctcoef *block = (dctcoef*)_block;
96+ stride /= sizeof(pixel);
97+
98+ block[0] += 32;
99+
100+ for( i = 0; i < 8; i++ )
101+ {
102+ const int a0 = block[i+0*8] + block[i+4*8];
103+ const int a2 = block[i+0*8] - block[i+4*8];
104+ const int a4 = (block[i+2*8]>>1) - block[i+6*8];
105+ const int a6 = (block[i+6*8]>>1) + block[i+2*8];
106+
107+ const int b0 = a0 + a6;
108+ const int b2 = a2 + a4;
109+ const int b4 = a2 - a4;
110+ const int b6 = a0 - a6;
111+
112+ const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1);
113+ const int a3 = block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1);
114+ const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1);
115+ const int a7 = block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1);
116+
117+ const int b1 = (a7>>2) + a1;
118+ const int b3 = a3 + (a5>>2);
119+ const int b5 = (a3>>2) - a5;
120+ const int b7 = a7 - (a1>>2);
121+
122+ block[i+0*8] = b0 + b7;
123+ block[i+7*8] = b0 - b7;
124+ block[i+1*8] = b2 + b5;
125+ block[i+6*8] = b2 - b5;
126+ block[i+2*8] = b4 + b3;
127+ block[i+5*8] = b4 - b3;
128+ block[i+3*8] = b6 + b1;
129+ block[i+4*8] = b6 - b1;
130+ }
131+ for( i = 0; i < 8; i++ )
132+ {
133+ const int a0 = block[0+i*8] + block[4+i*8];
134+ const int a2 = block[0+i*8] - block[4+i*8];
135+ const int a4 = (block[2+i*8]>>1) - block[6+i*8];
136+ const int a6 = (block[6+i*8]>>1) + block[2+i*8];
137+
138+ const int b0 = a0 + a6;
139+ const int b2 = a2 + a4;
140+ const int b4 = a2 - a4;
141+ const int b6 = a0 - a6;
142+
143+ const int a1 = -block[3+i*8] + block[5+i*8] - block[7+i*8] - (block[7+i*8]>>1);
144+ const int a3 = block[1+i*8] + block[7+i*8] - block[3+i*8] - (block[3+i*8]>>1);
145+ const int a5 = -block[1+i*8] + block[7+i*8] + block[5+i*8] + (block[5+i*8]>>1);
146+ const int a7 = block[3+i*8] + block[5+i*8] + block[1+i*8] + (block[1+i*8]>>1);
147+
148+ const int b1 = (a7>>2) + a1;
149+ const int b3 = a3 + (a5>>2);
150+ const int b5 = (a3>>2) - a5;
151+ const int b7 = a7 - (a1>>2);
152+
153+ dst[i + 0*stride] = CLIP( dst[i + 0*stride] + ((b0 + b7) >> 6) );
154+ dst[i + 1*stride] = CLIP( dst[i + 1*stride] + ((b2 + b5) >> 6) );
155+ dst[i + 2*stride] = CLIP( dst[i + 2*stride] + ((b4 + b3) >> 6) );
156+ dst[i + 3*stride] = CLIP( dst[i + 3*stride] + ((b6 + b1) >> 6) );
157+ dst[i + 4*stride] = CLIP( dst[i + 4*stride] + ((b6 - b1) >> 6) );
158+ dst[i + 5*stride] = CLIP( dst[i + 5*stride] + ((b4 - b3) >> 6) );
159+ dst[i + 6*stride] = CLIP( dst[i + 6*stride] + ((b2 - b5) >> 6) );
160+ dst[i + 7*stride] = CLIP( dst[i + 7*stride] + ((b0 - b7) >> 6) );
161+ }
162+}
163+
164+// assumes all AC coefs are 0
165+void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){
166+ int i, j;
167+ int dc = (((dctcoef*)block)[0] + 32) >> 6;
168+ INIT_CLIP
169+ pixel *dst = (pixel*)_dst;
170+ stride /= sizeof(pixel);
171+ for( j = 0; j < 4; j++ )
172+ {
173+ for( i = 0; i < 4; i++ )
174+ dst[i] = CLIP( dst[i] + dc );
175+ dst += stride;
176+ }
177+}
178+
179+void FUNCC(ff_h264_idct8_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){
180+ int i, j;
181+ int dc = (((dctcoef*)block)[0] + 32) >> 6;
182+ INIT_CLIP
183+ pixel *dst = (pixel*)_dst;
184+ stride /= sizeof(pixel);
185+ for( j = 0; j < 8; j++ )
186+ {
187+ for( i = 0; i < 8; i++ )
188+ dst[i] = CLIP( dst[i] + dc );
189+ dst += stride;
190+ }
191+}
192+
193+void FUNCC(ff_h264_idct_add16)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
194+ int i;
195+ for(i=0; i<16; i++){
196+ int nnz = nnzc[ scan8[i] ];
197+ if(nnz){
198+ if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
199+ else FUNCC(idct_internal )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1);
200+ }
201+ }
202+}
203+
204+void FUNCC(ff_h264_idct_add16intra)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
205+ int i;
206+ for(i=0; i<16; i++){
207+ if(nnzc[ scan8[i] ]) FUNCC(idct_internal )(dst + block_offset[i], block + i*16*sizeof(pixel), stride, 4, 6, 1);
208+ else if(((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
209+ }
210+}
211+
212+void FUNCC(ff_h264_idct8_add4)(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
213+ int i;
214+ for(i=0; i<16; i+=4){
215+ int nnz = nnzc[ scan8[i] ];
216+ if(nnz){
217+ if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct8_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
218+ else FUNCC(ff_h264_idct8_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
219+ }
220+ }
221+}
222+
223+void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
224+ int i;
225+ for(i=16; i<16+8; i++){
226+ if(nnzc[ scan8[i] ])
227+ FUNCC(ff_h264_idct_add )(dest[(i&4)>>2] + block_offset[i], block + i*16*sizeof(pixel), stride);
228+ else if(((dctcoef*)block)[i*16])
229+ FUNCC(ff_h264_idct_dc_add)(dest[(i&4)>>2] + block_offset[i], block + i*16*sizeof(pixel), stride);
230+ }
231+}
232+/**
233+ * IDCT transforms the 16 dc values and dequantizes them.
234+ * @param qp quantization parameter
235+ */
236+void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *_output, DCTELEM *_input, int qmul){
237+#define stride 16
238+ int i;
239+ int temp[16];
240+ static const uint8_t x_offset[4]={0, 2*stride, 8*stride, 10*stride};
241+ dctcoef *input = (dctcoef*)_input;
242+ dctcoef *output = (dctcoef*)_output;
243+
244+ for(i=0; i<4; i++){
245+ const int z0= input[4*i+0] + input[4*i+1];
246+ const int z1= input[4*i+0] - input[4*i+1];
247+ const int z2= input[4*i+2] - input[4*i+3];
248+ const int z3= input[4*i+2] + input[4*i+3];
249+
250+ temp[4*i+0]= z0+z3;
251+ temp[4*i+1]= z0-z3;
252+ temp[4*i+2]= z1-z2;
253+ temp[4*i+3]= z1+z2;
254+ }
255+
256+ for(i=0; i<4; i++){
257+ const int offset= x_offset[i];
258+ const int z0= temp[4*0+i] + temp[4*2+i];
259+ const int z1= temp[4*0+i] - temp[4*2+i];
260+ const int z2= temp[4*1+i] - temp[4*3+i];
261+ const int z3= temp[4*1+i] + temp[4*3+i];
262+
263+ output[stride* 0+offset]= ((((z0 + z3)*qmul + 128 ) >> 8));
264+ output[stride* 1+offset]= ((((z1 + z2)*qmul + 128 ) >> 8));
265+ output[stride* 4+offset]= ((((z1 - z2)*qmul + 128 ) >> 8));
266+ output[stride* 5+offset]= ((((z0 - z3)*qmul + 128 ) >> 8));
267+ }
268+#undef stride
269+}
270+
271+void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *_block, int qmul){
272+ const int stride= 16*2;
273+ const int xStride= 16;
274+ int a,b,c,d,e;
275+ dctcoef *block = (dctcoef*)_block;
276+
277+ a= block[stride*0 + xStride*0];
278+ b= block[stride*0 + xStride*1];
279+ c= block[stride*1 + xStride*0];
280+ d= block[stride*1 + xStride*1];
281+
282+ e= a-b;
283+ a= a+b;
284+ b= c-d;
285+ c= c+d;
286+
287+ block[stride*0 + xStride*0]= ((a+c)*qmul) >> 7;
288+ block[stride*0 + xStride*1]= ((e+b)*qmul) >> 7;
289+ block[stride*1 + xStride*0]= ((a-c)*qmul) >> 7;
290+ block[stride*1 + xStride*1]= ((e-b)*qmul) >> 7;
291+}
libavcodec/h264pred.c+343−21
@@ -28,17 +28,338 @@ · 27 unmodified lines
2828 #include "h264pred.h"
2929
3030 #define BIT_DEPTH 8
31−#include "h264pred_internal.h"
31+#include "h264pred_template.c"
3232 #undef BIT_DEPTH
3333
3434 #define BIT_DEPTH 9
35−#include "h264pred_internal.h"
35+#include "h264pred_template.c"
3636 #undef BIT_DEPTH
3737
3838 #define BIT_DEPTH 10
39−#include "h264pred_internal.h"
39+#include "h264pred_template.c"
4040 #undef BIT_DEPTH
4141
42+static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
43+ const int lt= src[-1-1*stride];
44+ LOAD_TOP_EDGE
45+ LOAD_TOP_RIGHT_EDGE
46+ uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2,
47+ (t0 + 2*t1 + t2 + 2) >> 2,
48+ (t1 + 2*t2 + t3 + 2) >> 2,
49+ (t2 + 2*t3 + t4 + 2) >> 2);
50+
51+ AV_WN32A(src+0*stride, v);
52+ AV_WN32A(src+1*stride, v);
53+ AV_WN32A(src+2*stride, v);
54+ AV_WN32A(src+3*stride, v);
55+}
56+
57+static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
58+ const int lt= src[-1-1*stride];
59+ LOAD_LEFT_EDGE
60+
61+ AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101);
62+ AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101);
63+ AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101);
64+ AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101);
65+}
66+
67+static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright, int stride){
68+ LOAD_TOP_EDGE
69+ LOAD_LEFT_EDGE
70+ const av_unused int unu0= t0;
71+ const av_unused int unu1= l0;
72+
73+ src[0+0*stride]=(l1 + t1)>>1;
74+ src[1+0*stride]=
75+ src[0+1*stride]=(l2 + t2)>>1;
76+ src[2+0*stride]=
77+ src[1+1*stride]=
78+ src[0+2*stride]=
79+ src[3+0*stride]=
80+ src[2+1*stride]=
81+ src[1+2*stride]=
82+ src[0+3*stride]=
83+ src[3+1*stride]=
84+ src[2+2*stride]=
85+ src[1+3*stride]=
86+ src[3+2*stride]=
87+ src[2+3*stride]=
88+ src[3+3*stride]=(l3 + t3)>>1;
89+}
90+
91+static void pred4x4_down_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
92+ LOAD_TOP_EDGE
93+ LOAD_TOP_RIGHT_EDGE
94+ LOAD_LEFT_EDGE
95+ LOAD_DOWN_LEFT_EDGE
96+
97+ src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
98+ src[1+0*stride]=
99+ src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
100+ src[2+0*stride]=
101+ src[1+1*stride]=
102+ src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + l4 + 2*l3 + 2)>>3;
103+ src[3+0*stride]=
104+ src[2+1*stride]=
105+ src[1+2*stride]=
106+ src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3 + l5 + 2*l4 + 2)>>3;
107+ src[3+1*stride]=
108+ src[2+2*stride]=
109+ src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l4 + l6 + 2*l5 + 2)>>3;
110+ src[3+2*stride]=
111+ src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l5 + l7 + 2*l6 + 2)>>3;
112+ src[3+3*stride]=(t6 + t7 + 1 + l6 + l7 + 1)>>2;
113+}
114+
115+static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
116+ LOAD_TOP_EDGE
117+ LOAD_TOP_RIGHT_EDGE
118+ LOAD_LEFT_EDGE
119+
120+ src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
121+ src[1+0*stride]=
122+ src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
123+ src[2+0*stride]=
124+ src[1+1*stride]=
125+ src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + 3*l3 + 2)>>3;
126+ src[3+0*stride]=
127+ src[2+1*stride]=
128+ src[1+2*stride]=
129+ src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3*4 + 2)>>3;
130+ src[3+1*stride]=
131+ src[2+2*stride]=
132+ src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l3*4 + 2)>>3;
133+ src[3+2*stride]=
134+ src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l3*4 + 2)>>3;
135+ src[3+3*stride]=(t6 + t7 + 1 + 2*l3 + 1)>>2;
136+}
137+
138+static void pred4x4_vertical_left_rv40(uint8_t *src, const uint8_t *topright, int stride,
139+ const int l0, const int l1, const int l2, const int l3, const int l4){
140+ LOAD_TOP_EDGE
141+ LOAD_TOP_RIGHT_EDGE
142+
143+ src[0+0*stride]=(2*t0 + 2*t1 + l1 + 2*l2 + l3 + 4)>>3;
144+ src[1+0*stride]=
145+ src[0+2*stride]=(t1 + t2 + 1)>>1;
146+ src[2+0*stride]=
147+ src[1+2*stride]=(t2 + t3 + 1)>>1;
148+ src[3+0*stride]=
149+ src[2+2*stride]=(t3 + t4+ 1)>>1;
150+ src[3+2*stride]=(t4 + t5+ 1)>>1;
151+ src[0+1*stride]=(t0 + 2*t1 + t2 + l2 + 2*l3 + l4 + 4)>>3;
152+ src[1+1*stride]=
153+ src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
154+ src[2+1*stride]=
155+ src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
156+ src[3+1*stride]=
157+ src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
158+ src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
159+}
160+
161+static void pred4x4_vertical_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
162+ LOAD_LEFT_EDGE
163+ LOAD_DOWN_LEFT_EDGE
164+
165+ pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4);
166+}
167+
168+static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
169+ LOAD_LEFT_EDGE
170+
171+ pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3);
172+}
173+
174+static void pred4x4_vertical_left_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
175+ LOAD_TOP_EDGE
176+ LOAD_TOP_RIGHT_EDGE
177+
178+ src[0+0*stride]=(t0 + t1 + 1)>>1;
179+ src[1+0*stride]=
180+ src[0+2*stride]=(t1 + t2 + 1)>>1;
181+ src[2+0*stride]=
182+ src[1+2*stride]=(t2 + t3 + 1)>>1;
183+ src[3+0*stride]=
184+ src[2+2*stride]=(t3 + t4 + 1)>>1;
185+ src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
186+ src[1+1*stride]=
187+ src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
188+ src[2+1*stride]=
189+ src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
190+ src[3+1*stride]=
191+ src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
192+ src[3+2*stride]=(t4 + 2*t5 + t6 + 2)>>2;
193+ src[3+3*stride]=(t5 + 2*t6 + t7 + 2)>>2;
194+}
195+
196+static void pred4x4_horizontal_up_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
197+ LOAD_LEFT_EDGE
198+ LOAD_DOWN_LEFT_EDGE
199+ LOAD_TOP_EDGE
200+ LOAD_TOP_RIGHT_EDGE
201+
202+ src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
203+ src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
204+ src[2+0*stride]=
205+ src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
206+ src[3+0*stride]=
207+ src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
208+ src[2+1*stride]=
209+ src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
210+ src[3+1*stride]=
211+ src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
212+ src[3+2*stride]=
213+ src[1+3*stride]=(l3 + 2*l4 + l5 + 2)>>2;
214+ src[0+3*stride]=
215+ src[2+2*stride]=(t6 + t7 + l3 + l4 + 2)>>2;
216+ src[2+3*stride]=(l4 + l5 + 1)>>1;
217+ src[3+3*stride]=(l4 + 2*l5 + l6 + 2)>>2;
218+}
219+
220+static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
221+ LOAD_LEFT_EDGE
222+ LOAD_TOP_EDGE
223+ LOAD_TOP_RIGHT_EDGE
224+
225+ src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
226+ src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
227+ src[2+0*stride]=
228+ src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
229+ src[3+0*stride]=
230+ src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
231+ src[2+1*stride]=
232+ src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
233+ src[3+1*stride]=
234+ src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
235+ src[3+2*stride]=
236+ src[1+3*stride]=l3;
237+ src[0+3*stride]=
238+ src[2+2*stride]=(t6 + t7 + 2*l3 + 2)>>2;
239+ src[2+3*stride]=
240+ src[3+3*stride]=l3;
241+}
242+
243+static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
244+ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
245+ uint8_t *top = src-stride;
246+ int y;
247+
248+ for (y = 0; y < 4; y++) {
249+ uint8_t *cm_in = cm + src[-1];
250+ src[0] = cm_in[top[0]];
251+ src[1] = cm_in[top[1]];
252+ src[2] = cm_in[top[2]];
253+ src[3] = cm_in[top[3]];
254+ src += stride;
255+ }
256+}
257+
258+static void pred16x16_plane_svq3_c(uint8_t *src, int stride){
259+ pred16x16_plane_compat_8_c(src, stride, 1, 0);
260+}
261+
262+static void pred16x16_plane_rv40_c(uint8_t *src, int stride){
263+ pred16x16_plane_compat_8_c(src, stride, 0, 1);
264+}
265+
266+static void pred16x16_tm_vp8_c(uint8_t *src, int stride){
267+ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
268+ uint8_t *top = src-stride;
269+ int y;
270+
271+ for (y = 0; y < 16; y++) {
272+ uint8_t *cm_in = cm + src[-1];
273+ src[0] = cm_in[top[0]];
274+ src[1] = cm_in[top[1]];
275+ src[2] = cm_in[top[2]];
276+ src[3] = cm_in[top[3]];
277+ src[4] = cm_in[top[4]];
278+ src[5] = cm_in[top[5]];
279+ src[6] = cm_in[top[6]];
280+ src[7] = cm_in[top[7]];
281+ src[8] = cm_in[top[8]];
282+ src[9] = cm_in[top[9]];
283+ src[10] = cm_in[top[10]];
284+ src[11] = cm_in[top[11]];
285+ src[12] = cm_in[top[12]];
286+ src[13] = cm_in[top[13]];
287+ src[14] = cm_in[top[14]];
288+ src[15] = cm_in[top[15]];
289+ src += stride;
290+ }
291+}
292+
293+static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){
294+ int i;
295+ int dc0;
296+
297+ dc0=0;
298+ for(i=0;i<8; i++)
299+ dc0+= src[-1+i*stride];
300+ dc0= 0x01010101*((dc0 + 4)>>3);
301+
302+ for(i=0; i<8; i++){
303+ ((uint32_t*)(src+i*stride))[0]=
304+ ((uint32_t*)(src+i*stride))[1]= dc0;
305+ }
306+}
307+
308+static void pred8x8_top_dc_rv40_c(uint8_t *src, int stride){
309+ int i;
310+ int dc0;
311+
312+ dc0=0;
313+ for(i=0;i<8; i++)
314+ dc0+= src[i-stride];
315+ dc0= 0x01010101*((dc0 + 4)>>3);
316+
317+ for(i=0; i<8; i++){
318+ ((uint32_t*)(src+i*stride))[0]=
319+ ((uint32_t*)(src+i*stride))[1]= dc0;
320+ }
321+}
322+
323+static void pred8x8_dc_rv40_c(uint8_t *src, int stride){
324+ int i;
325+ int dc0=0;
326+
327+ for(i=0;i<4; i++){
328+ dc0+= src[-1+i*stride] + src[i-stride];
329+ dc0+= src[4+i-stride];
330+ dc0+= src[-1+(i+4)*stride];
331+ }
332+ dc0= 0x01010101*((dc0 + 8)>>4);
333+
334+ for(i=0; i<4; i++){
335+ ((uint32_t*)(src+i*stride))[0]= dc0;
336+ ((uint32_t*)(src+i*stride))[1]= dc0;
337+ }
338+ for(i=4; i<8; i++){
339+ ((uint32_t*)(src+i*stride))[0]= dc0;
340+ ((uint32_t*)(src+i*stride))[1]= dc0;
341+ }
342+}
343+
344+static void pred8x8_tm_vp8_c(uint8_t *src, int stride){
345+ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
346+ uint8_t *top = src-stride;
347+ int y;
348+
349+ for (y = 0; y < 8; y++) {
350+ uint8_t *cm_in = cm + src[-1];
351+ src[0] = cm_in[top[0]];
352+ src[1] = cm_in[top[1]];
353+ src[2] = cm_in[top[2]];
354+ src[3] = cm_in[top[3]];
355+ src[4] = cm_in[top[4]];
356+ src[5] = cm_in[top[5]];
357+ src[6] = cm_in[top[6]];
358+ src[7] = cm_in[top[7]];
359+ src += stride;
360+ }
361+}
362+
42363 /**
43364 * Set the intra prediction function pointers.
44365 */
@@ -49,26 +370,27 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 4 unmodified lines
49370 #undef FUNCC
50371 #define FUNC(a, depth) a ## _ ## depth
51372 #define FUNCC(a, depth) a ## _ ## depth ## _c
373+#define FUNCD(a) a ## _c
52374
53375 #define H264_PRED(depth) \
54376 if(codec_id != CODEC_ID_RV40){\
55377 if(codec_id == CODEC_ID_VP8) {\
56− h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical_vp8 , depth);\
57− h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal_vp8 , depth);\
378+ h->pred4x4[VERT_PRED ]= FUNCD(pred4x4_vertical_vp8);\
379+ h->pred4x4[HOR_PRED ]= FUNCD(pred4x4_horizontal_vp8);\
58380 } else {\
59381 h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
60382 h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
61383 }\
62384 h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\
63385 if(codec_id == CODEC_ID_SVQ3)\
64− h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left_svq3, depth);\
386+ h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_svq3);\
65387 else\
66388 h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left , depth);\
67389 h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\
68390 h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\
69391 h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\
70392 if (codec_id == CODEC_ID_VP8) {\
71− h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left_vp8 , depth);\
393+ h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_vp8);\
72394 } else\
73395 h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left , depth);\
74396 h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up , depth);\
@@ -77,7 +399,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 2 unmodified lines
77399 h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\
78400 h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\
79401 } else {\
80− h->pred4x4[TM_VP8_PRED ]= FUNCC(pred4x4_tm_vp8 , depth);\
402+ h->pred4x4[TM_VP8_PRED ]= FUNCD(pred4x4_tm_vp8);\
81403 h->pred4x4[DC_127_PRED ]= FUNCC(pred4x4_127_dc , depth);\
82404 h->pred4x4[DC_129_PRED ]= FUNCC(pred4x4_129_dc , depth);\
83405 h->pred4x4[VERT_VP8_PRED ]= FUNCC(pred4x4_vertical , depth);\
@@ -87,18 +409,18 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 3 unmodified lines
87409 h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
88410 h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
89411 h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\
90− h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left_rv40 , depth);\
412+ h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_rv40);\
91413 h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\
92414 h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\
93415 h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\
94− h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left_rv40, depth);\
95− h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up_rv40, depth);\
416+ h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_rv40);\
417+ h->pred4x4[HOR_UP_PRED ]= FUNCD(pred4x4_horizontal_up_rv40);\
96418 h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\
97419 h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\
98420 h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\
99− h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCC(pred4x4_down_left_rv40_nodown, depth);\
100− h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCC(pred4x4_horizontal_up_rv40_nodown , depth);\
101− h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCC(pred4x4_vertical_left_rv40_nodown , depth);\
421+ h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_down_left_rv40_nodown);\
422+ h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCD(pred4x4_horizontal_up_rv40_nodown);\
423+ h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_vertical_left_rv40_nodown);\
102424 }\
103425 \
104426 h->pred8x8l[VERT_PRED ]= FUNCC(pred8x8l_vertical , depth);\
@@ -119,7 +441,7 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 14 unmodified lines
119441 if (codec_id != CODEC_ID_VP8) {\
120442 h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\
121443 } else\
122− h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_tm_vp8 , depth);\
444+ h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
123445 if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\
124446 h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
125447 h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
@@ -129,9 +451,9 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 3 unmodified lines
129451 h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
130452 h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
131453 }else{\
132− h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc_rv40 , depth);\
133− h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc_rv40 , depth);\
134− h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc_rv40 , depth);\
454+ h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\
455+ h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\
456+ h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\
135457 if (codec_id == CODEC_ID_VP8) {\
136458 h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc , depth);\
137459 h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\
@@ -144,13 +466,13 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 6 unmodified lines
144466 h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\
145467 switch(codec_id){\
146468 case CODEC_ID_SVQ3:\
147− h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane_svq3 , depth);\
469+ h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_svq3);\
148470 break;\
149471 case CODEC_ID_RV40:\
150− h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane_rv40 , depth);\
472+ h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_rv40);\
151473 break;\
152474 case CODEC_ID_VP8:\
153− h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_tm_vp8 , depth);\
475+ h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_tm_vp8);\
154476 h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\
155477 h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc , depth);\
156478 break;\
libavcodec/h264pred_template.c+975−0
@@ -0,0 +1,975 @@
1+/*
2+ * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3+ * Copyright (c) 2003-2011 Michael Niedermayer <michaelni@gmx.at>
4+ *
5+ * This file is part of Libav.
6+ *
7+ * Libav is free software; you can redistribute it and/or
8+ * modify it under the terms of the GNU Lesser General Public
9+ * License as published by the Free Software Foundation; either
10+ * version 2.1 of the License, or (at your option) any later version.
11+ *
12+ * Libav is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+ * Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public
18+ * License along with Libav; if not, write to the Free Software
19+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+ */
21+
22+/**
23+ * @file
24+ * H.264 / AVC / MPEG4 part10 prediction functions.
25+ * @author Michael Niedermayer <michaelni@gmx.at>
26+ */
27+
28+#include "mathops.h"
29+#include "high_bit_depth.h"
30+
31+static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){
32+ pixel *src = (pixel*)_src;
33+ int stride = _stride/sizeof(pixel);
34+ const pixel4 a= ((pixel4*)(src-stride))[0];
35+ ((pixel4*)(src+0*stride))[0]= a;
36+ ((pixel4*)(src+1*stride))[0]= a;
37+ ((pixel4*)(src+2*stride))[0]= a;
38+ ((pixel4*)(src+3*stride))[0]= a;
39+}
40+
41+static void FUNCC(pred4x4_horizontal)(uint8_t *_src, const uint8_t *topright, int _stride){
42+ pixel *src = (pixel*)_src;
43+ int stride = _stride/sizeof(pixel);
44+ ((pixel4*)(src+0*stride))[0]= PIXEL_SPLAT_X4(src[-1+0*stride]);
45+ ((pixel4*)(src+1*stride))[0]= PIXEL_SPLAT_X4(src[-1+1*stride]);
46+ ((pixel4*)(src+2*stride))[0]= PIXEL_SPLAT_X4(src[-1+2*stride]);
47+ ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(src[-1+3*stride]);
48+}
49+
50+static void FUNCC(pred4x4_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
51+ pixel *src = (pixel*)_src;
52+ int stride = _stride/sizeof(pixel);
53+ const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride]
54+ + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3;
55+
56+ ((pixel4*)(src+0*stride))[0]=
57+ ((pixel4*)(src+1*stride))[0]=
58+ ((pixel4*)(src+2*stride))[0]=
59+ ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);
60+}
61+
62+static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
63+ pixel *src = (pixel*)_src;
64+ int stride = _stride/sizeof(pixel);
65+ const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
66+
67+ ((pixel4*)(src+0*stride))[0]=
68+ ((pixel4*)(src+1*stride))[0]=
69+ ((pixel4*)(src+2*stride))[0]=
70+ ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);
71+}
72+
73+static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
74+ pixel *src = (pixel*)_src;
75+ int stride = _stride/sizeof(pixel);
76+ const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;
77+
78+ ((pixel4*)(src+0*stride))[0]=
79+ ((pixel4*)(src+1*stride))[0]=
80+ ((pixel4*)(src+2*stride))[0]=
81+ ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);
82+}
83+
84+static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
85+ pixel *src = (pixel*)_src;
86+ int stride = _stride/sizeof(pixel);
87+ ((pixel4*)(src+0*stride))[0]=
88+ ((pixel4*)(src+1*stride))[0]=
89+ ((pixel4*)(src+2*stride))[0]=
90+ ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1));
91+}
92+
93+static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
94+ pixel *src = (pixel*)_src;
95+ int stride = _stride/sizeof(pixel);
96+ ((pixel4*)(src+0*stride))[0]=
97+ ((pixel4*)(src+1*stride))[0]=
98+ ((pixel4*)(src+2*stride))[0]=
99+ ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))-1);
100+}
101+
102+static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
103+ pixel *src = (pixel*)_src;
104+ int stride = _stride/sizeof(pixel);
105+ ((pixel4*)(src+0*stride))[0]=
106+ ((pixel4*)(src+1*stride))[0]=
107+ ((pixel4*)(src+2*stride))[0]=
108+ ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))+1);
109+}
110+
111+
112+#define LOAD_TOP_RIGHT_EDGE\
113+ const int av_unused t4= topright[0];\
114+ const int av_unused t5= topright[1];\
115+ const int av_unused t6= topright[2];\
116+ const int av_unused t7= topright[3];\
117+
118+#define LOAD_DOWN_LEFT_EDGE\
119+ const int av_unused l4= src[-1+4*stride];\
120+ const int av_unused l5= src[-1+5*stride];\
121+ const int av_unused l6= src[-1+6*stride];\
122+ const int av_unused l7= src[-1+7*stride];\
123+
124+#define LOAD_LEFT_EDGE\
125+ const int av_unused l0= src[-1+0*stride];\
126+ const int av_unused l1= src[-1+1*stride];\
127+ const int av_unused l2= src[-1+2*stride];\
128+ const int av_unused l3= src[-1+3*stride];\
129+
130+#define LOAD_TOP_EDGE\
131+ const int av_unused t0= src[ 0-1*stride];\
132+ const int av_unused t1= src[ 1-1*stride];\
133+ const int av_unused t2= src[ 2-1*stride];\
134+ const int av_unused t3= src[ 3-1*stride];\
135+
136+static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright, int _stride){
137+ pixel *src = (pixel*)_src;
138+ int stride = _stride/sizeof(pixel);
139+ const int lt= src[-1-1*stride];
140+ LOAD_TOP_EDGE
141+ LOAD_LEFT_EDGE
142+
143+ src[0+3*stride]=(l3 + 2*l2 + l1 + 2)>>2;
144+ src[0+2*stride]=
145+ src[1+3*stride]=(l2 + 2*l1 + l0 + 2)>>2;
146+ src[0+1*stride]=
147+ src[1+2*stride]=
148+ src[2+3*stride]=(l1 + 2*l0 + lt + 2)>>2;
149+ src[0+0*stride]=
150+ src[1+1*stride]=
151+ src[2+2*stride]=
152+ src[3+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
153+ src[1+0*stride]=
154+ src[2+1*stride]=
155+ src[3+2*stride]=(lt + 2*t0 + t1 + 2)>>2;
156+ src[2+0*stride]=
157+ src[3+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
158+ src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2;
159+}
160+
161+static void FUNCC(pred4x4_down_left)(uint8_t *_src, const uint8_t *_topright, int _stride){
162+ pixel *src = (pixel*)_src;
163+ const pixel *topright = (const pixel*)_topright;
164+ int stride = _stride/sizeof(pixel);
165+ LOAD_TOP_EDGE
166+ LOAD_TOP_RIGHT_EDGE
167+// LOAD_LEFT_EDGE
168+
169+ src[0+0*stride]=(t0 + t2 + 2*t1 + 2)>>2;
170+ src[1+0*stride]=
171+ src[0+1*stride]=(t1 + t3 + 2*t2 + 2)>>2;
172+ src[2+0*stride]=
173+ src[1+1*stride]=
174+ src[0+2*stride]=(t2 + t4 + 2*t3 + 2)>>2;
175+ src[3+0*stride]=
176+ src[2+1*stride]=
177+ src[1+2*stride]=
178+ src[0+3*stride]=(t3 + t5 + 2*t4 + 2)>>2;
179+ src[3+1*stride]=
180+ src[2+2*stride]=
181+ src[1+3*stride]=(t4 + t6 + 2*t5 + 2)>>2;
182+ src[3+2*stride]=
183+ src[2+3*stride]=(t5 + t7 + 2*t6 + 2)>>2;
184+ src[3+3*stride]=(t6 + 3*t7 + 2)>>2;
185+}
186+
187+static void FUNCC(pred4x4_vertical_right)(uint8_t *_src, const uint8_t *topright, int _stride){
188+ pixel *src = (pixel*)_src;
189+ int stride = _stride/sizeof(pixel);
190+ const int lt= src[-1-1*stride];
191+ LOAD_TOP_EDGE
192+ LOAD_LEFT_EDGE
193+
194+ src[0+0*stride]=
195+ src[1+2*stride]=(lt + t0 + 1)>>1;
196+ src[1+0*stride]=
197+ src[2+2*stride]=(t0 + t1 + 1)>>1;
198+ src[2+0*stride]=
199+ src[3+2*stride]=(t1 + t2 + 1)>>1;
200+ src[3+0*stride]=(t2 + t3 + 1)>>1;
201+ src[0+1*stride]=
202+ src[1+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
203+ src[1+1*stride]=
204+ src[2+3*stride]=(lt + 2*t0 + t1 + 2)>>2;
205+ src[2+1*stride]=
206+ src[3+3*stride]=(t0 + 2*t1 + t2 + 2)>>2;
207+ src[3+1*stride]=(t1 + 2*t2 + t3 + 2)>>2;
208+ src[0+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
209+ src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
210+}
211+
212+static void FUNCC(pred4x4_vertical_left)(uint8_t *_src, const uint8_t *_topright, int _stride){
213+ pixel *src = (pixel*)_src;
214+ const pixel *topright = (const pixel*)_topright;
215+ int stride = _stride/sizeof(pixel);
216+ LOAD_TOP_EDGE
217+ LOAD_TOP_RIGHT_EDGE
218+
219+ src[0+0*stride]=(t0 + t1 + 1)>>1;
220+ src[1+0*stride]=
221+ src[0+2*stride]=(t1 + t2 + 1)>>1;
222+ src[2+0*stride]=
223+ src[1+2*stride]=(t2 + t3 + 1)>>1;
224+ src[3+0*stride]=
225+ src[2+2*stride]=(t3 + t4+ 1)>>1;
226+ src[3+2*stride]=(t4 + t5+ 1)>>1;
227+ src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
228+ src[1+1*stride]=
229+ src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
230+ src[2+1*stride]=
231+ src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
232+ src[3+1*stride]=
233+ src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
234+ src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
235+}
236+
237+static void FUNCC(pred4x4_horizontal_up)(uint8_t *_src, const uint8_t *topright, int _stride){
238+ pixel *src = (pixel*)_src;
239+ int stride = _stride/sizeof(pixel);
240+ LOAD_LEFT_EDGE
241+
242+ src[0+0*stride]=(l0 + l1 + 1)>>1;
243+ src[1+0*stride]=(l0 + 2*l1 + l2 + 2)>>2;
244+ src[2+0*stride]=
245+ src[0+1*stride]=(l1 + l2 + 1)>>1;
246+ src[3+0*stride]=
247+ src[1+1*stride]=(l1 + 2*l2 + l3 + 2)>>2;
248+ src[2+1*stride]=
249+ src[0+2*stride]=(l2 + l3 + 1)>>1;
250+ src[3+1*stride]=
251+ src[1+2*stride]=(l2 + 2*l3 + l3 + 2)>>2;
252+ src[3+2*stride]=
253+ src[1+3*stride]=
254+ src[0+3*stride]=
255+ src[2+2*stride]=
256+ src[2+3*stride]=
257+ src[3+3*stride]=l3;
258+}
259+
260+static void FUNCC(pred4x4_horizontal_down)(uint8_t *_src, const uint8_t *topright, int _stride){
261+ pixel *src = (pixel*)_src;
262+ int stride = _stride/sizeof(pixel);
263+ const int lt= src[-1-1*stride];
264+ LOAD_TOP_EDGE
265+ LOAD_LEFT_EDGE
266+
267+ src[0+0*stride]=
268+ src[2+1*stride]=(lt + l0 + 1)>>1;
269+ src[1+0*stride]=
270+ src[3+1*stride]=(l0 + 2*lt + t0 + 2)>>2;
271+ src[2+0*stride]=(lt + 2*t0 + t1 + 2)>>2;
272+ src[3+0*stride]=(t0 + 2*t1 + t2 + 2)>>2;
273+ src[0+1*stride]=
274+ src[2+2*stride]=(l0 + l1 + 1)>>1;
275+ src[1+1*stride]=
276+ src[3+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
277+ src[0+2*stride]=
278+ src[2+3*stride]=(l1 + l2+ 1)>>1;
279+ src[1+2*stride]=
280+ src[3+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
281+ src[0+3*stride]=(l2 + l3 + 1)>>1;
282+ src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
283+}
284+
285+static void FUNCC(pred16x16_vertical)(uint8_t *_src, int _stride){
286+ int i;
287+ pixel *src = (pixel*)_src;
288+ int stride = _stride/sizeof(pixel);
289+ const pixel4 a = ((pixel4*)(src-stride))[0];
290+ const pixel4 b = ((pixel4*)(src-stride))[1];
291+ const pixel4 c = ((pixel4*)(src-stride))[2];
292+ const pixel4 d = ((pixel4*)(src-stride))[3];
293+
294+ for(i=0; i<16; i++){
295+ ((pixel4*)(src+i*stride))[0] = a;
296+ ((pixel4*)(src+i*stride))[1] = b;
297+ ((pixel4*)(src+i*stride))[2] = c;
298+ ((pixel4*)(src+i*stride))[3] = d;
299+ }
300+}
301+
302+static void FUNCC(pred16x16_horizontal)(uint8_t *_src, int stride){
303+ int i;
304+ pixel *src = (pixel*)_src;
305+ stride /= sizeof(pixel);
306+
307+ for(i=0; i<16; i++){
308+ ((pixel4*)(src+i*stride))[0] =
309+ ((pixel4*)(src+i*stride))[1] =
310+ ((pixel4*)(src+i*stride))[2] =
311+ ((pixel4*)(src+i*stride))[3] = PIXEL_SPLAT_X4(src[-1+i*stride]);
312+ }
313+}
314+
315+#define PREDICT_16x16_DC(v)\
316+ for(i=0; i<16; i++){\
317+ AV_WN4P(src+ 0, v);\
318+ AV_WN4P(src+ 4, v);\
319+ AV_WN4P(src+ 8, v);\
320+ AV_WN4P(src+12, v);\
321+ src += stride;\
322+ }
323+
324+static void FUNCC(pred16x16_dc)(uint8_t *_src, int stride){
325+ int i, dc=0;
326+ pixel *src = (pixel*)_src;
327+ pixel4 dcsplat;
328+ stride /= sizeof(pixel);
329+
330+ for(i=0;i<16; i++){
331+ dc+= src[-1+i*stride];
332+ }
333+
334+ for(i=0;i<16; i++){
335+ dc+= src[i-stride];
336+ }
337+
338+ dcsplat = PIXEL_SPLAT_X4((dc+16)>>5);
339+ PREDICT_16x16_DC(dcsplat);
340+}
341+
342+static void FUNCC(pred16x16_left_dc)(uint8_t *_src, int stride){
343+ int i, dc=0;
344+ pixel *src = (pixel*)_src;
345+ pixel4 dcsplat;
346+ stride /= sizeof(pixel);
347+
348+ for(i=0;i<16; i++){
349+ dc+= src[-1+i*stride];
350+ }
351+
352+ dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
353+ PREDICT_16x16_DC(dcsplat);
354+}
355+
356+static void FUNCC(pred16x16_top_dc)(uint8_t *_src, int stride){
357+ int i, dc=0;
358+ pixel *src = (pixel*)_src;
359+ pixel4 dcsplat;
360+ stride /= sizeof(pixel);
361+
362+ for(i=0;i<16; i++){
363+ dc+= src[i-stride];
364+ }
365+
366+ dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
367+ PREDICT_16x16_DC(dcsplat);
368+}
369+
370+#define PRED16x16_X(n, v) \
371+static void FUNCC(pred16x16_##n##_dc)(uint8_t *_src, int stride){\
372+ int i;\
373+ pixel *src = (pixel*)_src;\
374+ stride /= sizeof(pixel);\
375+ PREDICT_16x16_DC(PIXEL_SPLAT_X4(v));\
376+}
377+
378+PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1);
379+PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0);
380+PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1);
381+
382+static inline void FUNCC(pred16x16_plane_compat)(uint8_t *_src, int _stride, const int svq3, const int rv40){
383+ int i, j, k;
384+ int a;
385+ INIT_CLIP
386+ pixel *src = (pixel*)_src;
387+ int stride = _stride/sizeof(pixel);
388+ const pixel * const src0 = src +7-stride;
389+ const pixel * src1 = src +8*stride-1;
390+ const pixel * src2 = src1-2*stride; // == src+6*stride-1;
391+ int H = src0[1] - src0[-1];
392+ int V = src1[0] - src2[ 0];
393+ for(k=2; k<=8; ++k) {
394+ src1 += stride; src2 -= stride;
395+ H += k*(src0[k] - src0[-k]);
396+ V += k*(src1[0] - src2[ 0]);
397+ }
398+ if(svq3){
399+ H = ( 5*(H/4) ) / 16;
400+ V = ( 5*(V/4) ) / 16;
401+
402+ /* required for 100% accuracy */
403+ i = H; H = V; V = i;
404+ }else if(rv40){
405+ H = ( H + (H>>2) ) >> 4;
406+ V = ( V + (V>>2) ) >> 4;
407+ }else{
408+ H = ( 5*H+32 ) >> 6;
409+ V = ( 5*V+32 ) >> 6;
410+ }
411+
412+ a = 16*(src1[0] + src2[16] + 1) - 7*(V+H);
413+ for(j=16; j>0; --j) {
414+ int b = a;
415+ a += V;
416+ for(i=-16; i<0; i+=4) {
417+ src[16+i] = CLIP((b ) >> 5);
418+ src[17+i] = CLIP((b+ H) >> 5);
419+ src[18+i] = CLIP((b+2*H) >> 5);
420+ src[19+i] = CLIP((b+3*H) >> 5);
421+ b += 4*H;
422+ }
423+ src += stride;
424+ }
425+}
426+
427+static void FUNCC(pred16x16_plane)(uint8_t *src, int stride){
428+ FUNCC(pred16x16_plane_compat)(src, stride, 0, 0);
429+}
430+
431+static void FUNCC(pred8x8_vertical)(uint8_t *_src, int _stride){
432+ int i;
433+ pixel *src = (pixel*)_src;
434+ int stride = _stride/sizeof(pixel);
435+ const pixel4 a= ((pixel4*)(src-stride))[0];
436+ const pixel4 b= ((pixel4*)(src-stride))[1];
437+
438+ for(i=0; i<8; i++){
439+ ((pixel4*)(src+i*stride))[0]= a;
440+ ((pixel4*)(src+i*stride))[1]= b;
441+ }
442+}
443+
444+static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){
445+ int i;
446+ pixel *src = (pixel*)_src;
447+ stride /= sizeof(pixel);
448+
449+ for(i=0; i<8; i++){
450+ ((pixel4*)(src+i*stride))[0]=
451+ ((pixel4*)(src+i*stride))[1]= PIXEL_SPLAT_X4(src[-1+i*stride]);
452+ }
453+}
454+
455+#define PRED8x8_X(n, v)\
456+static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\
457+ int i;\
458+ pixel *src = (pixel*)_src;\
459+ stride /= sizeof(pixel);\
460+ for(i=0; i<8; i++){\
461+ ((pixel4*)(src+i*stride))[0]=\
462+ ((pixel4*)(src+i*stride))[1]= PIXEL_SPLAT_X4(v);\
463+ }\
464+}
465+
466+PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1);
467+PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0);
468+PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1);
469+
470+static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){
471+ int i;
472+ int dc0, dc2;
473+ pixel4 dc0splat, dc2splat;
474+ pixel *src = (pixel*)_src;
475+ stride /= sizeof(pixel);
476+
477+ dc0=dc2=0;
478+ for(i=0;i<4; i++){
479+ dc0+= src[-1+i*stride];
480+ dc2+= src[-1+(i+4)*stride];
481+ }
482+ dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
483+ dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
484+
485+ for(i=0; i<4; i++){
486+ ((pixel4*)(src+i*stride))[0]=
487+ ((pixel4*)(src+i*stride))[1]= dc0splat;
488+ }
489+ for(i=4; i<8; i++){
490+ ((pixel4*)(src+i*stride))[0]=
491+ ((pixel4*)(src+i*stride))[1]= dc2splat;
492+ }
493+}
494+
495+static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){
496+ int i;
497+ int dc0, dc1;
498+ pixel4 dc0splat, dc1splat;
499+ pixel *src = (pixel*)_src;
500+ stride /= sizeof(pixel);
501+
502+ dc0=dc1=0;
503+ for(i=0;i<4; i++){
504+ dc0+= src[i-stride];
505+ dc1+= src[4+i-stride];
506+ }
507+ dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
508+ dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
509+
510+ for(i=0; i<4; i++){
511+ ((pixel4*)(src+i*stride))[0]= dc0splat;
512+ ((pixel4*)(src+i*stride))[1]= dc1splat;
513+ }
514+ for(i=4; i<8; i++){
515+ ((pixel4*)(src+i*stride))[0]= dc0splat;
516+ ((pixel4*)(src+i*stride))[1]= dc1splat;
517+ }
518+}
519+
520+static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){
521+ int i;
522+ int dc0, dc1, dc2;
523+ pixel4 dc0splat, dc1splat, dc2splat, dc3splat;
524+ pixel *src = (pixel*)_src;
525+ stride /= sizeof(pixel);
526+
527+ dc0=dc1=dc2=0;
528+ for(i=0;i<4; i++){
529+ dc0+= src[-1+i*stride] + src[i-stride];
530+ dc1+= src[4+i-stride];
531+ dc2+= src[-1+(i+4)*stride];
532+ }
533+ dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
534+ dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
535+ dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
536+ dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
537+
538+ for(i=0; i<4; i++){
539+ ((pixel4*)(src+i*stride))[0]= dc0splat;
540+ ((pixel4*)(src+i*stride))[1]= dc1splat;
541+ }
542+ for(i=4; i<8; i++){
543+ ((pixel4*)(src+i*stride))[0]= dc2splat;
544+ ((pixel4*)(src+i*stride))[1]= dc3splat;
545+ }
546+}
547+
548+//the following 4 function should not be optimized!
549+static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, int stride){
550+ FUNCC(pred8x8_top_dc)(src, stride);
551+ FUNCC(pred4x4_dc)(src, NULL, stride);
552+}
553+
554+static void FUNC(pred8x8_mad_cow_dc_0lt)(uint8_t *src, int stride){
555+ FUNCC(pred8x8_dc)(src, stride);
556+ FUNCC(pred4x4_top_dc)(src, NULL, stride);
557+}
558+
559+static void FUNC(pred8x8_mad_cow_dc_l00)(uint8_t *src, int stride){
560+ FUNCC(pred8x8_left_dc)(src, stride);
561+ FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride);
562+ FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride);
563+}
564+
565+static void FUNC(pred8x8_mad_cow_dc_0l0)(uint8_t *src, int stride){
566+ FUNCC(pred8x8_left_dc)(src, stride);
567+ FUNCC(pred4x4_128_dc)(src , NULL, stride);
568+ FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride);
569+}
570+
571+static void FUNCC(pred8x8_plane)(uint8_t *_src, int _stride){
572+ int j, k;
573+ int a;
574+ INIT_CLIP
575+ pixel *src = (pixel*)_src;
576+ int stride = _stride/sizeof(pixel);
577+ const pixel * const src0 = src +3-stride;
578+ const pixel * src1 = src +4*stride-1;
579+ const pixel * src2 = src1-2*stride; // == src+2*stride-1;
580+ int H = src0[1] - src0[-1];
581+ int V = src1[0] - src2[ 0];
582+ for(k=2; k<=4; ++k) {
583+ src1 += stride; src2 -= stride;
584+ H += k*(src0[k] - src0[-k]);
585+ V += k*(src1[0] - src2[ 0]);
586+ }
587+ H = ( 17*H+16 ) >> 5;
588+ V = ( 17*V+16 ) >> 5;
589+
590+ a = 16*(src1[0] + src2[8]+1) - 3*(V+H);
591+ for(j=8; j>0; --j) {
592+ int b = a;
593+ a += V;
594+ src[0] = CLIP((b ) >> 5);
595+ src[1] = CLIP((b+ H) >> 5);
596+ src[2] = CLIP((b+2*H) >> 5);
597+ src[3] = CLIP((b+3*H) >> 5);
598+ src[4] = CLIP((b+4*H) >> 5);
599+ src[5] = CLIP((b+5*H) >> 5);
600+ src[6] = CLIP((b+6*H) >> 5);
601+ src[7] = CLIP((b+7*H) >> 5);
602+ src += stride;
603+ }
604+}
605+
606+#define SRC(x,y) src[(x)+(y)*stride]
607+#define PL(y) \
608+ const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
609+#define PREDICT_8x8_LOAD_LEFT \
610+ const int l0 = ((has_topleft ? SRC(-1,-1) : SRC(-1,0)) \
611+ + 2*SRC(-1,0) + SRC(-1,1) + 2) >> 2; \
612+ PL(1) PL(2) PL(3) PL(4) PL(5) PL(6) \
613+ const int l7 av_unused = (SRC(-1,6) + 3*SRC(-1,7) + 2) >> 2
614+
615+#define PT(x) \
616+ const int t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
617+#define PREDICT_8x8_LOAD_TOP \
618+ const int t0 = ((has_topleft ? SRC(-1,-1) : SRC(0,-1)) \
619+ + 2*SRC(0,-1) + SRC(1,-1) + 2) >> 2; \
620+ PT(1) PT(2) PT(3) PT(4) PT(5) PT(6) \
621+ const int t7 av_unused = ((has_topright ? SRC(8,-1) : SRC(7,-1)) \
622+ + 2*SRC(7,-1) + SRC(6,-1) + 2) >> 2
623+
624+#define PTR(x) \
625+ t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
626+#define PREDICT_8x8_LOAD_TOPRIGHT \
627+ int t8, t9, t10, t11, t12, t13, t14, t15; \
628+ if(has_topright) { \
629+ PTR(8) PTR(9) PTR(10) PTR(11) PTR(12) PTR(13) PTR(14) \
630+ t15 = (SRC(14,-1) + 3*SRC(15,-1) + 2) >> 2; \
631+ } else t8=t9=t10=t11=t12=t13=t14=t15= SRC(7,-1);
632+
633+#define PREDICT_8x8_LOAD_TOPLEFT \
634+ const int lt = (SRC(-1,0) + 2*SRC(-1,-1) + SRC(0,-1) + 2) >> 2
635+
636+#define PREDICT_8x8_DC(v) \
637+ int y; \
638+ for( y = 0; y < 8; y++ ) { \
639+ ((pixel4*)src)[0] = \
640+ ((pixel4*)src)[1] = v; \
641+ src += stride; \
642+ }
643+
644+static void FUNCC(pred8x8l_128_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
645+{
646+ pixel *src = (pixel*)_src;
647+ int stride = _stride/sizeof(pixel);
648+
649+ PREDICT_8x8_DC(PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1)));
650+}
651+static void FUNCC(pred8x8l_left_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
652+{
653+ pixel *src = (pixel*)_src;
654+ int stride = _stride/sizeof(pixel);
655+
656+ PREDICT_8x8_LOAD_LEFT;
657+ const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7+4) >> 3);
658+ PREDICT_8x8_DC(dc);
659+}
660+static void FUNCC(pred8x8l_top_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
661+{
662+ pixel *src = (pixel*)_src;
663+ int stride = _stride/sizeof(pixel);
664+
665+ PREDICT_8x8_LOAD_TOP;
666+ const pixel4 dc = PIXEL_SPLAT_X4((t0+t1+t2+t3+t4+t5+t6+t7+4) >> 3);
667+ PREDICT_8x8_DC(dc);
668+}
669+static void FUNCC(pred8x8l_dc)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
670+{
671+ pixel *src = (pixel*)_src;
672+ int stride = _stride/sizeof(pixel);
673+
674+ PREDICT_8x8_LOAD_LEFT;
675+ PREDICT_8x8_LOAD_TOP;
676+ const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7
677+ +t0+t1+t2+t3+t4+t5+t6+t7+8) >> 4);
678+ PREDICT_8x8_DC(dc);
679+}
680+static void FUNCC(pred8x8l_horizontal)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
681+{
682+ pixel *src = (pixel*)_src;
683+ int stride = _stride/sizeof(pixel);
684+
685+ PREDICT_8x8_LOAD_LEFT;
686+#define ROW(y) ((pixel4*)(src+y*stride))[0] =\
687+ ((pixel4*)(src+y*stride))[1] = PIXEL_SPLAT_X4(l##y)
688+ ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
689+#undef ROW
690+}
691+static void FUNCC(pred8x8l_vertical)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
692+{
693+ int y;
694+ pixel *src = (pixel*)_src;
695+ int stride = _stride/sizeof(pixel);
696+
697+ PREDICT_8x8_LOAD_TOP;
698+ src[0] = t0;
699+ src[1] = t1;
700+ src[2] = t2;
701+ src[3] = t3;
702+ src[4] = t4;
703+ src[5] = t5;
704+ src[6] = t6;
705+ src[7] = t7;
706+ for( y = 1; y < 8; y++ ) {
707+ ((pixel4*)(src+y*stride))[0] = ((pixel4*)src)[0];
708+ ((pixel4*)(src+y*stride))[1] = ((pixel4*)src)[1];
709+ }
710+}
711+static void FUNCC(pred8x8l_down_left)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
712+{
713+ pixel *src = (pixel*)_src;
714+ int stride = _stride/sizeof(pixel);
715+ PREDICT_8x8_LOAD_TOP;
716+ PREDICT_8x8_LOAD_TOPRIGHT;
717+ SRC(0,0)= (t0 + 2*t1 + t2 + 2) >> 2;
718+ SRC(0,1)=SRC(1,0)= (t1 + 2*t2 + t3 + 2) >> 2;
719+ SRC(0,2)=SRC(1,1)=SRC(2,0)= (t2 + 2*t3 + t4 + 2) >> 2;
720+ SRC(0,3)=SRC(1,2)=SRC(2,1)=SRC(3,0)= (t3 + 2*t4 + t5 + 2) >> 2;
721+ SRC(0,4)=SRC(1,3)=SRC(2,2)=SRC(3,1)=SRC(4,0)= (t4 + 2*t5 + t6 + 2) >> 2;
722+ SRC(0,5)=SRC(1,4)=SRC(2,3)=SRC(3,2)=SRC(4,1)=SRC(5,0)= (t5 + 2*t6 + t7 + 2) >> 2;
723+ SRC(0,6)=SRC(1,5)=SRC(2,4)=SRC(3,3)=SRC(4,2)=SRC(5,1)=SRC(6,0)= (t6 + 2*t7 + t8 + 2) >> 2;
724+ SRC(0,7)=SRC(1,6)=SRC(2,5)=SRC(3,4)=SRC(4,3)=SRC(5,2)=SRC(6,1)=SRC(7,0)= (t7 + 2*t8 + t9 + 2) >> 2;
725+ SRC(1,7)=SRC(2,6)=SRC(3,5)=SRC(4,4)=SRC(5,3)=SRC(6,2)=SRC(7,1)= (t8 + 2*t9 + t10 + 2) >> 2;
726+ SRC(2,7)=SRC(3,6)=SRC(4,5)=SRC(5,4)=SRC(6,3)=SRC(7,2)= (t9 + 2*t10 + t11 + 2) >> 2;
727+ SRC(3,7)=SRC(4,6)=SRC(5,5)=SRC(6,4)=SRC(7,3)= (t10 + 2*t11 + t12 + 2) >> 2;
728+ SRC(4,7)=SRC(5,6)=SRC(6,5)=SRC(7,4)= (t11 + 2*t12 + t13 + 2) >> 2;
729+ SRC(5,7)=SRC(6,6)=SRC(7,5)= (t12 + 2*t13 + t14 + 2) >> 2;
730+ SRC(6,7)=SRC(7,6)= (t13 + 2*t14 + t15 + 2) >> 2;
731+ SRC(7,7)= (t14 + 3*t15 + 2) >> 2;
732+}
733+static void FUNCC(pred8x8l_down_right)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
734+{
735+ pixel *src = (pixel*)_src;
736+ int stride = _stride/sizeof(pixel);
737+ PREDICT_8x8_LOAD_TOP;
738+ PREDICT_8x8_LOAD_LEFT;
739+ PREDICT_8x8_LOAD_TOPLEFT;
740+ SRC(0,7)= (l7 + 2*l6 + l5 + 2) >> 2;
741+ SRC(0,6)=SRC(1,7)= (l6 + 2*l5 + l4 + 2) >> 2;
742+ SRC(0,5)=SRC(1,6)=SRC(2,7)= (l5 + 2*l4 + l3 + 2) >> 2;
743+ SRC(0,4)=SRC(1,5)=SRC(2,6)=SRC(3,7)= (l4 + 2*l3 + l2 + 2) >> 2;
744+ SRC(0,3)=SRC(1,4)=SRC(2,5)=SRC(3,6)=SRC(4,7)= (l3 + 2*l2 + l1 + 2) >> 2;
745+ SRC(0,2)=SRC(1,3)=SRC(2,4)=SRC(3,5)=SRC(4,6)=SRC(5,7)= (l2 + 2*l1 + l0 + 2) >> 2;
746+ SRC(0,1)=SRC(1,2)=SRC(2,3)=SRC(3,4)=SRC(4,5)=SRC(5,6)=SRC(6,7)= (l1 + 2*l0 + lt + 2) >> 2;
747+ SRC(0,0)=SRC(1,1)=SRC(2,2)=SRC(3,3)=SRC(4,4)=SRC(5,5)=SRC(6,6)=SRC(7,7)= (l0 + 2*lt + t0 + 2) >> 2;
748+ SRC(1,0)=SRC(2,1)=SRC(3,2)=SRC(4,3)=SRC(5,4)=SRC(6,5)=SRC(7,6)= (lt + 2*t0 + t1 + 2) >> 2;
749+ SRC(2,0)=SRC(3,1)=SRC(4,2)=SRC(5,3)=SRC(6,4)=SRC(7,5)= (t0 + 2*t1 + t2 + 2) >> 2;
750+ SRC(3,0)=SRC(4,1)=SRC(5,2)=SRC(6,3)=SRC(7,4)= (t1 + 2*t2 + t3 + 2) >> 2;
751+ SRC(4,0)=SRC(5,1)=SRC(6,2)=SRC(7,3)= (t2 + 2*t3 + t4 + 2) >> 2;
752+ SRC(5,0)=SRC(6,1)=SRC(7,2)= (t3 + 2*t4 + t5 + 2) >> 2;
753+ SRC(6,0)=SRC(7,1)= (t4 + 2*t5 + t6 + 2) >> 2;
754+ SRC(7,0)= (t5 + 2*t6 + t7 + 2) >> 2;
755+}
756+static void FUNCC(pred8x8l_vertical_right)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
757+{
758+ pixel *src = (pixel*)_src;
759+ int stride = _stride/sizeof(pixel);
760+ PREDICT_8x8_LOAD_TOP;
761+ PREDICT_8x8_LOAD_LEFT;
762+ PREDICT_8x8_LOAD_TOPLEFT;
763+ SRC(0,6)= (l5 + 2*l4 + l3 + 2) >> 2;
764+ SRC(0,7)= (l6 + 2*l5 + l4 + 2) >> 2;
765+ SRC(0,4)=SRC(1,6)= (l3 + 2*l2 + l1 + 2) >> 2;
766+ SRC(0,5)=SRC(1,7)= (l4 + 2*l3 + l2 + 2) >> 2;
767+ SRC(0,2)=SRC(1,4)=SRC(2,6)= (l1 + 2*l0 + lt + 2) >> 2;
768+ SRC(0,3)=SRC(1,5)=SRC(2,7)= (l2 + 2*l1 + l0 + 2) >> 2;
769+ SRC(0,1)=SRC(1,3)=SRC(2,5)=SRC(3,7)= (l0 + 2*lt + t0 + 2) >> 2;
770+ SRC(0,0)=SRC(1,2)=SRC(2,4)=SRC(3,6)= (lt + t0 + 1) >> 1;
771+ SRC(1,1)=SRC(2,3)=SRC(3,5)=SRC(4,7)= (lt + 2*t0 + t1 + 2) >> 2;
772+ SRC(1,0)=SRC(2,2)=SRC(3,4)=SRC(4,6)= (t0 + t1 + 1) >> 1;
773+ SRC(2,1)=SRC(3,3)=SRC(4,5)=SRC(5,7)= (t0 + 2*t1 + t2 + 2) >> 2;
774+ SRC(2,0)=SRC(3,2)=SRC(4,4)=SRC(5,6)= (t1 + t2 + 1) >> 1;
775+ SRC(3,1)=SRC(4,3)=SRC(5,5)=SRC(6,7)= (t1 + 2*t2 + t3 + 2) >> 2;
776+ SRC(3,0)=SRC(4,2)=SRC(5,4)=SRC(6,6)= (t2 + t3 + 1) >> 1;
777+ SRC(4,1)=SRC(5,3)=SRC(6,5)=SRC(7,7)= (t2 + 2*t3 + t4 + 2) >> 2;
778+ SRC(4,0)=SRC(5,2)=SRC(6,4)=SRC(7,6)= (t3 + t4 + 1) >> 1;
779+ SRC(5,1)=SRC(6,3)=SRC(7,5)= (t3 + 2*t4 + t5 + 2) >> 2;
780+ SRC(5,0)=SRC(6,2)=SRC(7,4)= (t4 + t5 + 1) >> 1;
781+ SRC(6,1)=SRC(7,3)= (t4 + 2*t5 + t6 + 2) >> 2;
782+ SRC(6,0)=SRC(7,2)= (t5 + t6 + 1) >> 1;
783+ SRC(7,1)= (t5 + 2*t6 + t7 + 2) >> 2;
784+ SRC(7,0)= (t6 + t7 + 1) >> 1;
785+}
786+static void FUNCC(pred8x8l_horizontal_down)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
787+{
788+ pixel *src = (pixel*)_src;
789+ int stride = _stride/sizeof(pixel);
790+ PREDICT_8x8_LOAD_TOP;
791+ PREDICT_8x8_LOAD_LEFT;
792+ PREDICT_8x8_LOAD_TOPLEFT;
793+ SRC(0,7)= (l6 + l7 + 1) >> 1;
794+ SRC(1,7)= (l5 + 2*l6 + l7 + 2) >> 2;
795+ SRC(0,6)=SRC(2,7)= (l5 + l6 + 1) >> 1;
796+ SRC(1,6)=SRC(3,7)= (l4 + 2*l5 + l6 + 2) >> 2;
797+ SRC(0,5)=SRC(2,6)=SRC(4,7)= (l4 + l5 + 1) >> 1;
798+ SRC(1,5)=SRC(3,6)=SRC(5,7)= (l3 + 2*l4 + l5 + 2) >> 2;
799+ SRC(0,4)=SRC(2,5)=SRC(4,6)=SRC(6,7)= (l3 + l4 + 1) >> 1;
800+ SRC(1,4)=SRC(3,5)=SRC(5,6)=SRC(7,7)= (l2 + 2*l3 + l4 + 2) >> 2;
801+ SRC(0,3)=SRC(2,4)=SRC(4,5)=SRC(6,6)= (l2 + l3 + 1) >> 1;
802+ SRC(1,3)=SRC(3,4)=SRC(5,5)=SRC(7,6)= (l1 + 2*l2 + l3 + 2) >> 2;
803+ SRC(0,2)=SRC(2,3)=SRC(4,4)=SRC(6,5)= (l1 + l2 + 1) >> 1;
804+ SRC(1,2)=SRC(3,3)=SRC(5,4)=SRC(7,5)= (l0 + 2*l1 + l2 + 2) >> 2;
805+ SRC(0,1)=SRC(2,2)=SRC(4,3)=SRC(6,4)= (l0 + l1 + 1) >> 1;
806+ SRC(1,1)=SRC(3,2)=SRC(5,3)=SRC(7,4)= (lt + 2*l0 + l1 + 2) >> 2;
807+ SRC(0,0)=SRC(2,1)=SRC(4,2)=SRC(6,3)= (lt + l0 + 1) >> 1;
808+ SRC(1,0)=SRC(3,1)=SRC(5,2)=SRC(7,3)= (l0 + 2*lt + t0 + 2) >> 2;
809+ SRC(2,0)=SRC(4,1)=SRC(6,2)= (t1 + 2*t0 + lt + 2) >> 2;
810+ SRC(3,0)=SRC(5,1)=SRC(7,2)= (t2 + 2*t1 + t0 + 2) >> 2;
811+ SRC(4,0)=SRC(6,1)= (t3 + 2*t2 + t1 + 2) >> 2;
812+ SRC(5,0)=SRC(7,1)= (t4 + 2*t3 + t2 + 2) >> 2;
813+ SRC(6,0)= (t5 + 2*t4 + t3 + 2) >> 2;
814+ SRC(7,0)= (t6 + 2*t5 + t4 + 2) >> 2;
815+}
816+static void FUNCC(pred8x8l_vertical_left)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
817+{
818+ pixel *src = (pixel*)_src;
819+ int stride = _stride/sizeof(pixel);
820+ PREDICT_8x8_LOAD_TOP;
821+ PREDICT_8x8_LOAD_TOPRIGHT;
822+ SRC(0,0)= (t0 + t1 + 1) >> 1;
823+ SRC(0,1)= (t0 + 2*t1 + t2 + 2) >> 2;
824+ SRC(0,2)=SRC(1,0)= (t1 + t2 + 1) >> 1;
825+ SRC(0,3)=SRC(1,1)= (t1 + 2*t2 + t3 + 2) >> 2;
826+ SRC(0,4)=SRC(1,2)=SRC(2,0)= (t2 + t3 + 1) >> 1;
827+ SRC(0,5)=SRC(1,3)=SRC(2,1)= (t2 + 2*t3 + t4 + 2) >> 2;
828+ SRC(0,6)=SRC(1,4)=SRC(2,2)=SRC(3,0)= (t3 + t4 + 1) >> 1;
829+ SRC(0,7)=SRC(1,5)=SRC(2,3)=SRC(3,1)= (t3 + 2*t4 + t5 + 2) >> 2;
830+ SRC(1,6)=SRC(2,4)=SRC(3,2)=SRC(4,0)= (t4 + t5 + 1) >> 1;
831+ SRC(1,7)=SRC(2,5)=SRC(3,3)=SRC(4,1)= (t4 + 2*t5 + t6 + 2) >> 2;
832+ SRC(2,6)=SRC(3,4)=SRC(4,2)=SRC(5,0)= (t5 + t6 + 1) >> 1;
833+ SRC(2,7)=SRC(3,5)=SRC(4,3)=SRC(5,1)= (t5 + 2*t6 + t7 + 2) >> 2;
834+ SRC(3,6)=SRC(4,4)=SRC(5,2)=SRC(6,0)= (t6 + t7 + 1) >> 1;
835+ SRC(3,7)=SRC(4,5)=SRC(5,3)=SRC(6,1)= (t6 + 2*t7 + t8 + 2) >> 2;
836+ SRC(4,6)=SRC(5,4)=SRC(6,2)=SRC(7,0)= (t7 + t8 + 1) >> 1;
837+ SRC(4,7)=SRC(5,5)=SRC(6,3)=SRC(7,1)= (t7 + 2*t8 + t9 + 2) >> 2;
838+ SRC(5,6)=SRC(6,4)=SRC(7,2)= (t8 + t9 + 1) >> 1;
839+ SRC(5,7)=SRC(6,5)=SRC(7,3)= (t8 + 2*t9 + t10 + 2) >> 2;
840+ SRC(6,6)=SRC(7,4)= (t9 + t10 + 1) >> 1;
841+ SRC(6,7)=SRC(7,5)= (t9 + 2*t10 + t11 + 2) >> 2;
842+ SRC(7,6)= (t10 + t11 + 1) >> 1;
843+ SRC(7,7)= (t10 + 2*t11 + t12 + 2) >> 2;
844+}
845+static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft, int has_topright, int _stride)
846+{
847+ pixel *src = (pixel*)_src;
848+ int stride = _stride/sizeof(pixel);
849+ PREDICT_8x8_LOAD_LEFT;
850+ SRC(0,0)= (l0 + l1 + 1) >> 1;
851+ SRC(1,0)= (l0 + 2*l1 + l2 + 2) >> 2;
852+ SRC(0,1)=SRC(2,0)= (l1 + l2 + 1) >> 1;
853+ SRC(1,1)=SRC(3,0)= (l1 + 2*l2 + l3 + 2) >> 2;
854+ SRC(0,2)=SRC(2,1)=SRC(4,0)= (l2 + l3 + 1) >> 1;
855+ SRC(1,2)=SRC(3,1)=SRC(5,0)= (l2 + 2*l3 + l4 + 2) >> 2;
856+ SRC(0,3)=SRC(2,2)=SRC(4,1)=SRC(6,0)= (l3 + l4 + 1) >> 1;
857+ SRC(1,3)=SRC(3,2)=SRC(5,1)=SRC(7,0)= (l3 + 2*l4 + l5 + 2) >> 2;
858+ SRC(0,4)=SRC(2,3)=SRC(4,2)=SRC(6,1)= (l4 + l5 + 1) >> 1;
859+ SRC(1,4)=SRC(3,3)=SRC(5,2)=SRC(7,1)= (l4 + 2*l5 + l6 + 2) >> 2;
860+ SRC(0,5)=SRC(2,4)=SRC(4,3)=SRC(6,2)= (l5 + l6 + 1) >> 1;
861+ SRC(1,5)=SRC(3,4)=SRC(5,3)=SRC(7,2)= (l5 + 2*l6 + l7 + 2) >> 2;
862+ SRC(0,6)=SRC(2,5)=SRC(4,4)=SRC(6,3)= (l6 + l7 + 1) >> 1;
863+ SRC(1,6)=SRC(3,5)=SRC(5,4)=SRC(7,3)= (l6 + 3*l7 + 2) >> 2;
864+ SRC(0,7)=SRC(1,7)=SRC(2,6)=SRC(2,7)=SRC(3,6)=
865+ SRC(3,7)=SRC(4,5)=SRC(4,6)=SRC(4,7)=SRC(5,5)=
866+ SRC(5,6)=SRC(5,7)=SRC(6,4)=SRC(6,5)=SRC(6,6)=
867+ SRC(6,7)=SRC(7,4)=SRC(7,5)=SRC(7,6)=SRC(7,7)= l7;
868+}
869+#undef PREDICT_8x8_LOAD_LEFT
870+#undef PREDICT_8x8_LOAD_TOP
871+#undef PREDICT_8x8_LOAD_TOPLEFT
872+#undef PREDICT_8x8_LOAD_TOPRIGHT
873+#undef PREDICT_8x8_DC
874+#undef PTR
875+#undef PT
876+#undef PL
877+#undef SRC
878+
879+static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const DCTELEM *_block, int stride){
880+ int i;
881+ pixel *pix = (pixel*)_pix;
882+ const dctcoef *block = (const dctcoef*)_block;
883+ stride /= sizeof(pixel);
884+ pix -= stride;
885+ for(i=0; i<4; i++){
886+ pixel v = pix[0];
887+ pix[1*stride]= v += block[0];
888+ pix[2*stride]= v += block[4];
889+ pix[3*stride]= v += block[8];
890+ pix[4*stride]= v + block[12];
891+ pix++;
892+ block++;
893+ }
894+}
895+
896+static void FUNCC(pred4x4_horizontal_add)(uint8_t *_pix, const DCTELEM *_block, int stride){
897+ int i;
898+ pixel *pix = (pixel*)_pix;
899+ const dctcoef *block = (const dctcoef*)_block;
900+ stride /= sizeof(pixel);
901+ for(i=0; i<4; i++){
902+ pixel v = pix[-1];
903+ pix[0]= v += block[0];
904+ pix[1]= v += block[1];
905+ pix[2]= v += block[2];
906+ pix[3]= v + block[3];
907+ pix+= stride;
908+ block+= 4;
909+ }
910+}
911+
912+static void FUNCC(pred8x8l_vertical_add)(uint8_t *_pix, const DCTELEM *_block, int stride){
913+ int i;
914+ pixel *pix = (pixel*)_pix;
915+ const dctcoef *block = (const dctcoef*)_block;
916+ stride /= sizeof(pixel);
917+ pix -= stride;
918+ for(i=0; i<8; i++){
919+ pixel v = pix[0];
920+ pix[1*stride]= v += block[0];
921+ pix[2*stride]= v += block[8];
922+ pix[3*stride]= v += block[16];
923+ pix[4*stride]= v += block[24];
924+ pix[5*stride]= v += block[32];
925+ pix[6*stride]= v += block[40];
926+ pix[7*stride]= v += block[48];
927+ pix[8*stride]= v + block[56];
928+ pix++;
929+ block++;
930+ }
931+}
932+
933+static void FUNCC(pred8x8l_horizontal_add)(uint8_t *_pix, const DCTELEM *_block, int stride){
934+ int i;
935+ pixel *pix = (pixel*)_pix;
936+ const dctcoef *block = (const dctcoef*)_block;
937+ stride /= sizeof(pixel);
938+ for(i=0; i<8; i++){
939+ pixel v = pix[-1];
940+ pix[0]= v += block[0];
941+ pix[1]= v += block[1];
942+ pix[2]= v += block[2];
943+ pix[3]= v += block[3];
944+ pix[4]= v += block[4];
945+ pix[5]= v += block[5];
946+ pix[6]= v += block[6];
947+ pix[7]= v + block[7];
948+ pix+= stride;
949+ block+= 8;
950+ }
951+}
952+
953+static void FUNCC(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
954+ int i;
955+ for(i=0; i<16; i++)
956+ FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
957+}
958+
959+static void FUNCC(pred16x16_horizontal_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
960+ int i;
961+ for(i=0; i<16; i++)
962+ FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
963+}
964+
965+static void FUNCC(pred8x8_vertical_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
966+ int i;
967+ for(i=0; i<4; i++)
968+ FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
969+}
970+
971+static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
972+ int i;
973+ for(i=0; i<4; i++)
974+ FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
975+}
libavcodec/high_bit_depth.h+85−0
@@ -0,0 +1,85 @@
1+#include "dsputil.h"
2+
3+#ifndef BIT_DEPTH
4+#define BIT_DEPTH 8
5+#endif
6+
7+#ifdef AVCODEC_H264_HIGH_DEPTH_H
8+# undef pixel
9+# undef pixel2
10+# undef pixel4
11+# undef dctcoef
12+# undef INIT_CLIP
13+# undef no_rnd_avg_pixel4
14+# undef rnd_avg_pixel4
15+# undef AV_RN2P
16+# undef AV_RN4P
17+# undef AV_WN2P
18+# undef AV_WN4P
19+# undef AV_WN4PA
20+# undef CLIP
21+# undef FUNC
22+# undef FUNCC
23+# undef av_clip_pixel
24+# undef PIXEL_SPLAT_X4
25+#else
26+# define AVCODEC_H264_HIGH_DEPTH_H
27+# define CLIP_PIXEL(depth)\
28+ static inline uint16_t av_clip_pixel_ ## depth (int p)\
29+ {\
30+ const int pixel_max = (1 << depth)-1;\
31+ return (p & ~pixel_max) ? (-p)>>31 & pixel_max : p;\
32+ }
33+
34+CLIP_PIXEL( 9)
35+CLIP_PIXEL(10)
36+#endif
37+
38+#if BIT_DEPTH > 8
39+# define pixel uint16_t
40+# define pixel2 uint32_t
41+# define pixel4 uint64_t
42+# define dctcoef int32_t
43+
44+# define INIT_CLIP
45+# define no_rnd_avg_pixel4 no_rnd_avg64
46+# define rnd_avg_pixel4 rnd_avg64
47+# define AV_RN2P AV_RN32
48+# define AV_RN4P AV_RN64
49+# define AV_WN2P AV_WN32
50+# define AV_WN4P AV_WN64
51+# define AV_WN4PA AV_WN64A
52+# define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
53+#else
54+# define pixel uint8_t
55+# define pixel2 uint16_t
56+# define pixel4 uint32_t
57+# define dctcoef int16_t
58+
59+# define INIT_CLIP uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
60+# define no_rnd_avg_pixel4 no_rnd_avg32
61+# define rnd_avg_pixel4 rnd_avg32
62+# define AV_RN2P AV_RN16
63+# define AV_RN4P AV_RN32
64+# define AV_WN2P AV_WN16
65+# define AV_WN4P AV_WN32
66+# define AV_WN4PA AV_WN32A
67+# define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
68+#endif
69+
70+#if BIT_DEPTH == 8
71+# define av_clip_pixel(a) av_clip_uint8(a)
72+# define CLIP(a) cm[a]
73+# define FUNC(a) a ## _8
74+# define FUNCC(a) a ## _8_c
75+#elif BIT_DEPTH == 9
76+# define av_clip_pixel(a) av_clip_pixel_9(a)
77+# define CLIP(a) av_clip_pixel_9(a)
78+# define FUNC(a) a ## _9
79+# define FUNCC(a) a ## _9_c
80+#elif BIT_DEPTH == 10
81+# define av_clip_pixel(a) av_clip_pixel_10(a)
82+# define CLIP(a) av_clip_pixel_10(a)
83+# define FUNC(a) a ## _10
84+# define FUNCC(a) a ## _10_c
85+#endif
libavcodec/lpc.c+6−6
@@ -158,7 +158,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 157 unmodified lines
158158 const int32_t *samples, int blocksize, int min_order,
159159 int max_order, int precision,
160160 int32_t coefs[][MAX_LPC_ORDER], int *shift,
161− enum AVLPCType lpc_type, int lpc_passes,
161+ enum FFLPCType lpc_type, int lpc_passes,
162162 int omethod, int max_shift, int zero_shift)
163163 {
164164 double autoc[MAX_LPC_ORDER+1];
@@ -168,7 +168,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 3 unmodified lines
168168 int opt_order;
169169
170170 assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&
171− lpc_type > AV_LPC_TYPE_FIXED);
171+ lpc_type > FF_LPC_TYPE_FIXED);
172172
173173 /* reinit LPC context if parameters have changed */
174174 if (blocksize != s->blocksize || max_order != s->max_order ||
@@ -177,7 +177,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 2 unmodified lines
177177 ff_lpc_init(s, blocksize, max_order, lpc_type);
178178 }
179179
180− if (lpc_type == AV_LPC_TYPE_LEVINSON) {
180+ if (lpc_type == FF_LPC_TYPE_LEVINSON) {
181181 double *windowed_samples = s->windowed_samples + max_order;
182182
183183 s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
@@ -188,7 +188,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 4 unmodified lines
188188
189189 for(i=0; i<max_order; i++)
190190 ref[i] = fabs(lpc[i][i]);
191− } else if (lpc_type == AV_LPC_TYPE_CHOLESKY) {
191+ } else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
192192 LLSModel m[2];
193193 double var[MAX_LPC_ORDER+1], av_uninit(weight);
194194
@@ -241,13 +241,13 @@ int ff_lpc_calc_coefs(LPCContext *s, · 46 unmodified lines
241241 }
242242
243243 av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
244− enum AVLPCType lpc_type)
244+ enum FFLPCType lpc_type)
245245 {
246246 s->blocksize = blocksize;
247247 s->max_order = max_order;
248248 s->lpc_type = lpc_type;
249249
250− if (lpc_type == AV_LPC_TYPE_LEVINSON) {
250+ if (lpc_type == FF_LPC_TYPE_LEVINSON) {
251251 s->windowed_samples = av_mallocz((blocksize + max_order + 2) *
252252 sizeof(*s->windowed_samples));
253253 if (!s->windowed_samples)
libavcodec/lpc.h+14−3
@@ -35,11 +35,22 @@ · 34 unmodified lines
3535 #define MIN_LPC_ORDER 1
3636 #define MAX_LPC_ORDER 32
3737
38+/**
39+ * LPC analysis type
40+ */
41+enum FFLPCType {
42+ FF_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
43+ FF_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
44+ FF_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
45+ FF_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion
46+ FF_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
47+ FF_LPC_TYPE_NB , ///< Not part of ABI
48+};
3849
3950 typedef struct LPCContext {
4051 int blocksize;
4152 int max_order;
42− enum AVLPCType lpc_type;
53+ enum FFLPCType lpc_type;
4354 double *windowed_samples;
4455
4556 /**
@@ -77,14 +88,14 @@ int ff_lpc_calc_coefs(LPCContext *s, · 31 unmodified lines
7788 const int32_t *samples, int blocksize, int min_order,
7889 int max_order, int precision,
7990 int32_t coefs[][MAX_LPC_ORDER], int *shift,
80− enum AVLPCType lpc_type, int lpc_passes,
91+ enum FFLPCType lpc_type, int lpc_passes,
8192 int omethod, int max_shift, int zero_shift);
8293
8394 /**
8495 * Initialize LPCContext.
8596 */
8697 int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
87− enum AVLPCType lpc_type);
98+ enum FFLPCType lpc_type);
8899 void ff_lpc_init_x86(LPCContext *s);
89100
90101 /**
libavcodec/mlib/dsputil_mlib.c+2−2
@@ -421,13 +421,13 @@ static void ff_fdct_mlib(DCTELEM *data) · 420 unmodified lines
421421
422422 void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)
423423 {
424− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
424+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
425425
426426 c->get_pixels = get_pixels_mlib;
427427 c->diff_pixels = diff_pixels_mlib;
428428 c->add_pixels_clamped = add_pixels_clamped_mlib;
429429
430− if (!h264_high_depth) {
430+ if (!high_bit_depth) {
431431 c->put_pixels_tab[0][0] = put_pixels16_mlib;
432432 c->put_pixels_tab[0][1] = put_pixels16_x2_mlib;
433433 c->put_pixels_tab[0][2] = put_pixels16_y2_mlib;
libavcodec/options.c+12−8
@@ -103,7 +103,7 @@ static const AVOption options[]={ · 102 unmodified lines
103103 {"umh", "umh motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" },
104104 {"iter", "iter motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" },
105105 {"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
106−{"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, {.dbl=0}, INT_MIN, INT_MAX},
106+{"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX},
107107 {"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, {.dbl = 12 }, INT_MIN, INT_MAX, V|E},
108108 {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
109109 {"ac", "set number of audio channels", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
@@ -224,7 +224,7 @@ static const AVOption options[]={ · 114 unmodified lines
224224 {"left", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"},
225225 {"plane", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"},
226226 {"median", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"},
227−{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), FF_OPT_TYPE_RATIONAL, {.dbl=0}, 0, 10, V|E},
227+{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), FF_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E},
228228 {"debug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"},
229229 {"pict", "picture info", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},
230230 {"rc", "rate control", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_RC }, INT_MIN, INT_MAX, V|E, "debug"},
@@ -380,12 +380,14 @@ static const AVOption options[]={ · 149 unmodified lines
380380 {"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_VLC }, INT_MIN, INT_MAX, V|E, "flags2"},
381381 {"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, {.dbl = 40 }, 1, INT_MAX, V|E},
382382 {"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, {.dbl = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
383−{"lpc_coeff_precision", "LPC coefficient precision (FLAC)", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|E},
384383 {"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
385384 {"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
386−{"prediction_order_method", "search method for selecting prediction order", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
387−{"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
388−{"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
385+#if FF_API_FLAC_GLOBAL_OPTS
386+{"lpc_coeff_precision", "deprecated, use flac-specific options", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|E},
387+{"prediction_order_method", "deprecated, use flac-specific options", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
388+{"min_partition_order", "deprecated, use flac-specific options", OFFSET(min_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
389+{"max_partition_order", "deprecated, use flac-specific options", OFFSET(max_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
390+#endif
389391 {"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT64, {.dbl = 0 }, 0, INT64_MAX, V|E},
390392 {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"},
391393 {"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NON_LINEAR_QUANT }, INT_MIN, INT_MAX, V|E, "flags2"},
@@ -416,12 +418,14 @@ static const AVOption options[]={ · 24 unmodified lines
416418 {"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"},
417419 {"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E},
418420 {"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX },
419−{"lpc_type", "specify LPC algorithm", OFFSET(lpc_type), FF_OPT_TYPE_INT, {.dbl = AV_LPC_TYPE_DEFAULT }, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E},
421+#if FF_API_FLAC_GLOBAL_OPTS
422+{"lpc_type", "deprecated, use flac-specific options", OFFSET(lpc_type), FF_OPT_TYPE_INT, {.dbl = AV_LPC_TYPE_DEFAULT }, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E},
420423 {"none", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_NONE }, INT_MIN, INT_MAX, A|E, "lpc_type"},
421424 {"fixed", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, A|E, "lpc_type"},
422425 {"levinson", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, A|E, "lpc_type"},
423426 {"cholesky", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, A|E, "lpc_type"},
424−{"lpc_passes", "number of passes to use for Cholesky factorization during LPC analysis", OFFSET(lpc_passes), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
427+{"lpc_passes", "deprecated, use flac-specific options", OFFSET(lpc_passes), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
428+#endif
425429 {"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E},
426430 {"thread_type", "select multithreading type", OFFSET(thread_type), FF_OPT_TYPE_INT, {.dbl = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|E|D, "thread_type"},
427431 {"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"},
libavcodec/ppc/dsputil_altivec.c+3−3
@@ -1384,7 +1384,7 @@ static void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int l · 1383 unmodified lines
13841384
13851385 void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx)
13861386 {
1387− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
1387+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
13881388
13891389 c->pix_abs[0][1] = sad16_x2_altivec;
13901390 c->pix_abs[0][2] = sad16_y2_altivec;
@@ -1399,10 +1399,10 @@ void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
13991399 c->pix_sum = pix_sum_altivec;
14001400 c->diff_pixels = diff_pixels_altivec;
14011401 c->get_pixels = get_pixels_altivec;
1402− if (!h264_high_depth)
1402+ if (!high_bit_depth)
14031403 c->clear_block = clear_block_altivec;
14041404 c->add_bytes= add_bytes_altivec;
1405− if (!h264_high_depth) {
1405+ if (!high_bit_depth) {
14061406 c->put_pixels_tab[0][0] = put_pixels16_altivec;
14071407 /* the two functions do the same thing, so use the same code */
14081408 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_altivec;
libavcodec/ppc/dsputil_ppc.c+2−2
@@ -153,11 +153,11 @@ static void prefetch_ppc(void *mem, int stride, int h) · 152 unmodified lines
153153
154154 void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
155155 {
156− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
156+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
157157
158158 // Common optimizations whether AltiVec is available or not
159159 c->prefetch = prefetch_ppc;
160− if (!h264_high_depth) {
160+ if (!high_bit_depth) {
161161 switch (check_dcbzl_effect()) {
162162 case 32:
163163 c->clear_blocks = clear_blocks_dcbz32_ppc;
libavcodec/ppc/h264_altivec.c+2−2
@@ -965,10 +965,10 @@ H264_WEIGHT( 8, 8) · 964 unmodified lines
965965 H264_WEIGHT( 8, 4)
966966
967967 void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
968− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
968+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
969969
970970 if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
971− if (!h264_high_depth) {
971+ if (!high_bit_depth) {
972972 c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
973973 c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
974974
libavcodec/ps2/dsputil_mmi.c+2−2
@@ -142,9 +142,9 @@ static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_siz · 141 unmodified lines
142142 void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
143143 {
144144 const int idct_algo= avctx->idct_algo;
145− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
145+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
146146
147− if (!h264_high_depth) {
147+ if (!high_bit_depth) {
148148 c->clear_blocks = clear_blocks_mmi;
149149
150150 c->put_pixels_tab[1][0] = put_pixels8_mmi;
libavcodec/ra144enc.c+2−2
@@ -54,7 +54,7 @@ static av_cold int ra144_encode_init(AVCodecContext * avctx) · 53 unmodified lines
5454 ractx->lpc_coef[1] = ractx->lpc_tables[1];
5555 ractx->avctx = avctx;
5656 ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
57− AV_LPC_TYPE_LEVINSON);
57+ FF_LPC_TYPE_LEVINSON);
5858 return ret;
5959 }
6060
@@ -461,7 +461,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 400 unmodified lines
461461 32)];
462462
463463 ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,
464− LPC_ORDER, 16, lpc_coefs, shift, AV_LPC_TYPE_LEVINSON,
464+ LPC_ORDER, 16, lpc_coefs, shift, FF_LPC_TYPE_LEVINSON,
465465 0, ORDER_METHOD_EST, 12, 0);
466466 for (i = 0; i < LPC_ORDER; i++)
467467 block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
libavcodec/sh4/dsputil_align.c+4−4
@@ -333,9 +333,9 @@ DEFFUNC(avg,no_rnd,xy,16,OP_XY,PACK) · 332 unmodified lines
333333
334334 void dsputil_init_align(DSPContext* c, AVCodecContext *avctx)
335335 {
336− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
336+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
337337
338− if (!h264_high_depth) {
338+ if (!high_bit_depth) {
339339 c->put_pixels_tab[0][0] = put_rnd_pixels16_o;
340340 c->put_pixels_tab[0][1] = put_rnd_pixels16_x;
341341 c->put_pixels_tab[0][2] = put_rnd_pixels16_y;
@@ -405,7 +405,7 @@ void dsputil_init_align(DSPContext* c, AVCodecContext *avctx) · 63 unmodified lines
405405 dspfunc(avg_qpel, 1, 8);
406406 /* dspfunc(avg_no_rnd_qpel, 1, 8); */
407407
408− if (!h264_high_depth) {
408+ if (!high_bit_depth) {
409409 dspfunc(put_h264_qpel, 0, 16);
410410 dspfunc(put_h264_qpel, 1, 8);
411411 dspfunc(put_h264_qpel, 2, 4);
@@ -415,7 +415,7 @@ void dsputil_init_align(DSPContext* c, AVCodecContext *avctx) · 3 unmodified lines
415415 }
416416
417417 #undef dspfunc
418− if (!h264_high_depth) {
418+ if (!high_bit_depth) {
419419 c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_sh4;
420420 c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_sh4;
421421 c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_sh4;
libavcodec/sh4/dsputil_sh4.c+2−2
@@ -92,10 +92,10 @@ static void idct_add(uint8_t *dest, int line_size, DCTELEM *block) · 91 unmodified lines
9292 void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
9393 {
9494 const int idct_algo= avctx->idct_algo;
95− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
95+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
9696 dsputil_init_align(c,avctx);
9797
98− if (!h264_high_depth)
98+ if (!high_bit_depth)
9999 c->clear_blocks = clear_blocks_sh4;
100100 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){
101101 c->idct_put = idct_put;
libavcodec/sparc/dsputil_vis.c+2−2
@@ -3953,7 +3953,7 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) · 3952 unmodified lines
39533953 {
39543954 /* VIS-specific optimizations */
39553955 int accel = vis_level ();
3956− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
3956+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
39573957
39583958 if (accel & ACCEL_SPARC_VIS) {
39593959 if(avctx->idct_algo==FF_IDCT_SIMPLEVIS){
@@ -3963,7 +3963,7 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) · 3 unmodified lines
39633963 c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
39643964 }
39653965
3966− if (!h264_high_depth) {
3966+ if (!high_bit_depth) {
39673967 c->put_pixels_tab[0][0] = MC_put_o_16_vis;
39683968 c->put_pixels_tab[0][1] = MC_put_x_16_vis;
39693969 c->put_pixels_tab[0][2] = MC_put_y_16_vis;
libavcodec/utils.c+3−3
@@ -1297,9 +1297,9 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) · 1296 unmodified lines
12971297 unsigned int ff_toupper4(unsigned int x)
12981298 {
12991299 return toupper( x &0xFF)
1300− + (toupper((x>>8 )&0xFF)<<8 )
1301− + (toupper((x>>16)&0xFF)<<16)
1302− + (toupper((x>>24)&0xFF)<<24);
1300+ + (toupper((x>>8 )&0xFF)<<8 )
1301+ + (toupper((x>>16)&0xFF)<<16)
1302+ + (toupper((x>>24)&0xFF)<<24);
13031303 }
13041304
13051305 #if !HAVE_PTHREADS
libavcodec/version.h+3−0
@@ -62,5 +62,8 @@ · 61 unmodified lines
6262 #ifndef FF_API_OLD_FF_PICT_TYPES
6363 #define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
6464 #endif
65+#ifndef FF_API_FLAC_GLOBAL_OPTS
66+#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
67+#endif
6568
6669 #endif /* AVCODEC_VERSION_H */
libavcodec/x86/dsputil_mmx.c+18−18
@@ -2322,7 +2322,7 @@ float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); · 2321 unmodified lines
23222322 void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
23232323 {
23242324 int mm_flags = av_get_cpu_flags();
2325− const int h264_high_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
2325+ const int high_bit_depth = avctx->codec_id == CODEC_ID_H264 && avctx->bits_per_raw_sample > 8;
23262326
23272327 if (avctx->dsp_mask) {
23282328 if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
@@ -2404,7 +2404,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 75 unmodified lines
24042404 c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
24052405 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
24062406 c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
2407− if (!h264_high_depth) {
2407+ if (!high_bit_depth) {
24082408 c->clear_block = clear_block_mmx;
24092409 c->clear_blocks = clear_blocks_mmx;
24102410 if ((mm_flags & AV_CPU_FLAG_SSE) &&
@@ -2421,7 +2421,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 10 unmodified lines
24212421 c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \
24222422 c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU
24232423
2424− if (!h264_high_depth) {
2424+ if (!high_bit_depth) {
24252425 SET_HPEL_FUNCS(put, 0, 16, mmx);
24262426 SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx);
24272427 SET_HPEL_FUNCS(avg, 0, 16, mmx);
@@ -2436,13 +2436,13 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
24362436 c->gmc= gmc_mmx;
24372437 #endif
24382438 #if ARCH_X86_32 && HAVE_YASM
2439− if (!h264_high_depth)
2439+ if (!high_bit_depth)
24402440 c->emulated_edge_mc = emulated_edge_mc_mmx;
24412441 #endif
24422442
24432443 c->add_bytes= add_bytes_mmx;
24442444
2445− if (!h264_high_depth)
2445+ if (!high_bit_depth)
24462446 c->draw_edges = draw_edges_mmx;
24472447
24482448 if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
@@ -2451,7 +2451,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 2 unmodified lines
24512451 }
24522452
24532453 #if HAVE_YASM
2454− if (!h264_high_depth) {
2454+ if (!high_bit_depth) {
24552455 c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_mmx_rnd;
24562456 c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_mmx;
24572457 }
@@ -2463,7 +2463,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 5 unmodified lines
24632463 if (mm_flags & AV_CPU_FLAG_MMX2) {
24642464 c->prefetch = prefetch_mmx2;
24652465
2466− if (!h264_high_depth) {
2466+ if (!high_bit_depth) {
24672467 c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
24682468 c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
24692469
@@ -2480,7 +2480,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 10 unmodified lines
24802480 }
24812481
24822482 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
2483− if (!h264_high_depth) {
2483+ if (!high_bit_depth) {
24842484 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
24852485 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
24862486 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
@@ -2529,7 +2529,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 42 unmodified lines
25292529 SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2);
25302530 SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2);
25312531
2532− if (!h264_high_depth) {
2532+ if (!high_bit_depth) {
25332533 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2);
25342534 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2);
25352535 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2);
@@ -2547,7 +2547,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 11 unmodified lines
25472547 c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_mmx2;
25482548 c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_mmx2;
25492549
2550− if (!h264_high_depth) {
2550+ if (!high_bit_depth) {
25512551 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_mmx2_rnd;
25522552 c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_mmx2;
25532553 c->avg_h264_chroma_pixels_tab[2]= ff_avg_h264_chroma_mc2_mmx2;
@@ -2564,7 +2564,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 10 unmodified lines
25642564 } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
25652565 c->prefetch = prefetch_3dnow;
25662566
2567− if (!h264_high_depth) {
2567+ if (!high_bit_depth) {
25682568 c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
25692569 c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
25702570
@@ -2602,7 +2602,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 31 unmodified lines
26022602 SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow);
26032603 SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow);
26042604
2605− if (!h264_high_depth) {
2605+ if (!high_bit_depth) {
26062606 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow);
26072607 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow);
26082608 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow);
@@ -2617,7 +2617,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
26172617 SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);
26182618
26192619 #if HAVE_YASM
2620− if (!h264_high_depth) {
2620+ if (!high_bit_depth) {
26212621 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_3dnow_rnd;
26222622 c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_3dnow;
26232623 }
@@ -2635,7 +2635,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 11 unmodified lines
26352635 c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;
26362636 if((mm_flags & AV_CPU_FLAG_SSE2) && !(mm_flags & AV_CPU_FLAG_3DNOW)){
26372637 // these functions are slower than mmx on AMD, but faster on Intel
2638− if (!h264_high_depth) {
2638+ if (!high_bit_depth) {
26392639 c->put_pixels_tab[0][0] = put_pixels16_sse2;
26402640 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_sse2;
26412641 c->avg_pixels_tab[0][0] = avg_pixels16_sse2;
@@ -2643,7 +2643,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 1 unmodified line
26432643 }
26442644 }
26452645 if(mm_flags & AV_CPU_FLAG_SSE2){
2646− if (!h264_high_depth) {
2646+ if (!high_bit_depth) {
26472647 H264_QPEL_FUNCS(0, 1, sse2);
26482648 H264_QPEL_FUNCS(0, 2, sse2);
26492649 H264_QPEL_FUNCS(0, 3, sse2);
@@ -2660,7 +2660,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 10 unmodified lines
26602660 }
26612661 #if HAVE_SSSE3
26622662 if(mm_flags & AV_CPU_FLAG_SSSE3){
2663− if (!h264_high_depth) {
2663+ if (!high_bit_depth) {
26642664 H264_QPEL_FUNCS(1, 0, ssse3);
26652665 H264_QPEL_FUNCS(1, 1, ssse3);
26662666 H264_QPEL_FUNCS(1, 2, ssse3);
@@ -2675,7 +2675,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
26752675 H264_QPEL_FUNCS(3, 3, ssse3);
26762676 }
26772677 #if HAVE_YASM
2678− if (!h264_high_depth) {
2678+ if (!high_bit_depth) {
26792679 c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd;
26802680 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_ssse3_rnd;
26812681 c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_ssse3;
@@ -2737,7 +2737,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 55 unmodified lines
27372737 }
27382738 }
27392739
2740− if (!h264_high_depth)
2740+ if (!high_bit_depth)
27412741 c->emulated_edge_mc = emulated_edge_mc_sse;
27422742 c->gmc= gmc_sse;
27432743 #endif
libavformat/utils.c+5−5
@@ -3048,12 +3048,12 @@ static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacke · 3047 unmodified lines
30483048 {
30493049 AVStream *st = s->streams[ pkt ->stream_index];
30503050 AVStream *st2= s->streams[ next->stream_index];
3051− int64_t a= st2->time_base.num * (int64_t)st ->time_base.den;
3052− int64_t b= st ->time_base.num * (int64_t)st2->time_base.den;
3053− int64_t dts1 = av_rescale_rnd(pkt->dts, b, a, AV_ROUND_DOWN);
3054− if (dts1==next->dts && dts1==av_rescale_rnd(pkt->dts, b, a, AV_ROUND_UP))
3051+ int comp = av_compare_ts(next->dts, st2->time_base, pkt->dts,
3052+ st->time_base);
3053+
3054+ if (comp == 0)
30553055 return pkt->stream_index < next->stream_index;
3056− return dts1 < next->dts;
3056+ return comp > 0;
30573057 }
30583058
30593059 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){
libavutil/opt.h+3−0
@@ -67,6 +67,9 @@ typedef struct AVOption { · 66 unmodified lines
6767 union {
6868 double dbl;
6969 const char *str;
70+ /* TODO those are unused now */
71+ int64_t i64;
72+ AVRational q;
7073 } default_val;
7174 double min; ///< minimum valid value for the option
7275 double max; ///< maximum valid value for the option
libavutil/pixfmt.h+1−1
@@ -136,7 +136,7 @@ enum PixelFormat { · 135 unmodified lines
136136 PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
137137 PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
138138
139− //the following 4 formats are deprecated and should be replaced by PIX_FMT_YUV420P16* with the bpp stored seperately
139+ //the following 6 formats are deprecated and should be replaced by PIX_FMT_YUV420P16* with the bpp stored seperately
140140 PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
141141 PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
142142 PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
libswscale/utils.c+4−0
@@ -107,9 +107,13 @@ const char *swscale_license(void) · 106 unmodified lines
107107 || (x)==PIX_FMT_YUV440P \
108108 || (x)==PIX_FMT_MONOWHITE \
109109 || (x)==PIX_FMT_MONOBLACK \
110+ || (x)==PIX_FMT_YUV420P9LE \
111+ || (x)==PIX_FMT_YUV420P10LE \
110112 || (x)==PIX_FMT_YUV420P16LE \
111113 || (x)==PIX_FMT_YUV422P16LE \
112114 || (x)==PIX_FMT_YUV444P16LE \
115+ || (x)==PIX_FMT_YUV420P9BE \
116+ || (x)==PIX_FMT_YUV420P10BE \
113117 || (x)==PIX_FMT_YUV420P16BE \
114118 || (x)==PIX_FMT_YUV422P16BE \
115119 || (x)==PIX_FMT_YUV444P16BE \
tests/fate/h264.mak+14−0
@@ -127,6 +127,13 @@ FATE_H264 = aud_mw_e \ · 126 unmodified lines
127127 frext-hpcvflnl_bcrm_a \
128128 frext-hpcvmolq_brcm_b \
129129 frext-hpcvnl_brcm_a \
130+ frext-pph10i1_panasonic_a \
131+ frext-pph10i2_panasonic_a \
132+ frext-pph10i3_panasonic_a \
133+ frext-pph10i4_panasonic_a \
134+ frext-pph10i5_panasonic_a \
135+ frext-pph10i6_panasonic_a \
136+ frext-pph10i7_panasonic_a \
130137 hcbp2_hhi_a \
131138 hcmp1_hhi_a \
132139 ls_sva_d \
@@ -301,6 +308,13 @@ fate-h264-conformance-frext-hpcvfl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-co · 168 unmodified lines
301308 fate-h264-conformance-frext-hpcvflnl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVFLNL_BRCM_A.264 -vsync 0
302309 fate-h264-conformance-frext-hpcvmolq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVMOLQ_BRCM_B.264
303310 fate-h264-conformance-frext-hpcvnl_brcm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVNL_BRCM_A.264
311+fate-h264-conformance-frext-pph10i1_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I1_Panasonic_A.264
312+fate-h264-conformance-frext-pph10i2_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I2_Panasonic_A.264
313+fate-h264-conformance-frext-pph10i3_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I3_Panasonic_A.264
314+fate-h264-conformance-frext-pph10i4_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I4_Panasonic_A.264
315+fate-h264-conformance-frext-pph10i5_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I5_Panasonic_A.264
316+fate-h264-conformance-frext-pph10i6_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I6_Panasonic_A.264
317+fate-h264-conformance-frext-pph10i7_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I7_Panasonic_A.264
304318 fate-h264-conformance-hcbp2_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCBP2_HHI_A.264
305319 fate-h264-conformance-hcmp1_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCMP1_HHI_A.264
306320 fate-h264-conformance-ls_sva_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/LS_SVA_D.264
tests/ref/fate/h264-conformance-frext-pph10i1_panasonic_a+10−0
@@ -0,0 +1,10 @@
1+0, 0, 2764800, 0xcc4df07d
2+0, 3600, 2764800, 0x85f9e6d4
3+0, 7200, 2764800, 0x23ffe90d
4+0, 10800, 2764800, 0xf0a6d453
5+0, 14400, 2764800, 0x913a6392
6+0, 18000, 2764800, 0xcc5f9736
7+0, 21600, 2764800, 0x43f9f9ce
8+0, 25200, 2764800, 0xc874b44e
9+0, 28800, 2764800, 0x83b665e6
10+0, 32400, 2764800, 0x5ea2e31e
tests/ref/fate/h264-conformance-frext-pph10i2_panasonic_a+10−0
@@ -0,0 +1,10 @@
1+0, 0, 2764800, 0x4f710132
2+0, 3600, 2764800, 0x57e5b713
3+0, 7200, 2764800, 0xcca01477
4+0, 10800, 2764800, 0xa19a95cd
5+0, 14400, 2764800, 0x700a757d
6+0, 18000, 2764800, 0xd8c6f60f
7+0, 21600, 2764800, 0x95a1bbc7
8+0, 25200, 2764800, 0x0582077a
9+0, 28800, 2764800, 0x91595f91
10+0, 32400, 2764800, 0xf5fe034a
tests/ref/fate/h264-conformance-frext-pph10i3_panasonic_a+10−0
@@ -0,0 +1,10 @@
1+0, 0, 2764800, 0xda69f69e
2+0, 3600, 2764800, 0x29ed832f
3+0, 7200, 2764800, 0xb3244cc4
4+0, 10800, 2764800, 0xe41a312c
5+0, 14400, 2764800, 0xac0b344b
6+0, 18000, 2764800, 0xc585aa20
7+0, 21600, 2764800, 0x0952054c
8+0, 25200, 2764800, 0xd1a02f87
9+0, 28800, 2764800, 0xfcbfe87c
10+0, 32400, 2764800, 0xe4e9b8a2
tests/ref/fate/h264-conformance-frext-pph10i4_panasonic_a+19−0
@@ -0,0 +1,19 @@
1+0, 0, 6220800, 0xca2a2a5e
2+0, 3600, 6220800, 0x8009a65e
3+0, 7200, 6220800, 0x63e72b3b
4+0, 10800, 6220800, 0x7459a1cc
5+0, 14400, 6220800, 0x02191aa9
6+0, 18000, 6220800, 0x88dca590
7+0, 21600, 6220800, 0x56dd150a
8+0, 25200, 6220800, 0x5f56a56f
9+0, 28800, 6220800, 0x67ada4b7
10+0, 32400, 6220800, 0x88dca590
11+0, 36000, 6220800, 0xd3b09fe5
12+0, 39600, 6220800, 0x2223998c
13+0, 43200, 6220800, 0x5e5b2da5
14+0, 46800, 6220800, 0x88dca590
15+0, 50400, 6220800, 0x5e5b2da5
16+0, 54000, 6220800, 0x88dca590
17+0, 57600, 6220800, 0x5e5b2da5
18+0, 61200, 6220800, 0x88dca590
19+0, 64800, 6220800, 0x26e1ec8b
tests/ref/fate/h264-conformance-frext-pph10i5_panasonic_a+10−0
@@ -0,0 +1,10 @@
1+0, 0, 6220800, 0x1df58ce9
2+0, 3600, 6220800, 0x8f2859ce
3+0, 7200, 6220800, 0x229cc7ff
4+0, 10800, 6220800, 0x73e86984
5+0, 14400, 6220800, 0xb6d4504b
6+0, 18000, 6220800, 0x4e7d4883
7+0, 21600, 6220800, 0xbec3f0f7
8+0, 25200, 6220800, 0x1d9af065
9+0, 28800, 6220800, 0x44851549
10+0, 32400, 6220800, 0xfcf8728e
tests/ref/fate/h264-conformance-frext-pph10i6_panasonic_a+10−0
@@ -0,0 +1,10 @@
1+0, 0, 6220800, 0x408daf70
2+0, 3600, 6220800, 0x59b254a3
3+0, 7200, 6220800, 0x4cf4279c
4+0, 10800, 6220800, 0x5c9437ae
5+0, 14400, 6220800, 0x986c3eb8
6+0, 18000, 6220800, 0x23fd883e
7+0, 21600, 6220800, 0x84f222fe
8+0, 25200, 6220800, 0xe7f91107
9+0, 28800, 6220800, 0xb544b31e
10+0, 32400, 6220800, 0x1ebdde56
tests/ref/fate/h264-conformance-frext-pph10i7_panasonic_a+10−0
@@ -0,0 +1,10 @@
1+0, 0, 6220800, 0xf81873fe
2+0, 3600, 6220800, 0x7b96fbdc
3+0, 7200, 6220800, 0x75dbafc4
4+0, 10800, 6220800, 0x7524301e
5+0, 14400, 6220800, 0x0f3621ab
6+0, 18000, 6220800, 0xa5e25b35
7+0, 21600, 6220800, 0x063a8116
8+0, 25200, 6220800, 0x48ebc8ff
9+0, 28800, 6220800, 0x1f635df8
10+0, 32400, 6220800, 0xe282c8bd

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