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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162011-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
162011-05-07 - xxxxxxx - lavfi 2.5.0 - avcodec.h222011-05-07 - xxxxxxx - lavfi 2.5.0 - avcodec.h
17 Add libavfilter/avcodec.h header and avfilter_copy_frame_props()23 Add libavfilter/avcodec.h header and avfilter_copy_frame_props()
18 function.24 function.
ffmpeg.c+8−8
@@ -292,7 +292,6 @@ typedef struct AVOutputStream { · 291 unmodified lines
292 int resample_pix_fmt;292 int resample_pix_fmt;
293 293
294 float frame_aspect_ratio;294 float frame_aspect_ratio;
295
296 /* forced key frames */295 /* forced key frames */
297 int64_t *forced_kf_pts;296 int64_t *forced_kf_pts;
298 int forced_kf_count;297 int forced_kf_count;
@@ -1505,7 +1504,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 1206 unmodified lines
1505 AVFormatContext *os;1504 AVFormatContext *os;
1506 AVOutputStream *ost;1505 AVOutputStream *ost;
1507 int ret, i;1506 int ret, i;
1508 int got_picture;1507 int got_output;
1509 AVFrame picture;1508 AVFrame picture;
1510 void *buffer_to_free = NULL;1509 void *buffer_to_free = NULL;
1511 static unsigned int samples_size= 0;1510 static unsigned int samples_size= 0;
@@ -1537,7 +1536,7 @@ static int output_packet(AVInputStream *ist, int ist_index, · 25 unmodified lines
1537 pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);1536 pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
1538 1537
1539 //while we have more to decode or while the decoder did output something on EOF1538 //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)) {
1541 uint8_t *data_buf, *decoded_data_buf;1540 uint8_t *data_buf, *decoded_data_buf;
1542 int data_size, decoded_data_size;1541 int data_size, decoded_data_size;
1543 handle_eof:1542 handle_eof:
@@ -1573,9 +1572,10 @@ static int output_packet(AVInputStream *ist, int ist_index, · 29 unmodified lines
1573 avpkt.data += ret;1572 avpkt.data += ret;
1574 avpkt.size -= ret;1573 avpkt.size -= ret;
1575 data_size = ret;1574 data_size = ret;
1575 got_output = decoded_data_size > 0;
1576 /* Some bug in mpeg audio decoder gives */1576 /* Some bug in mpeg audio decoder gives */
1577 /* decoded_data_size < 0, it seems they are overflows */1577 /* decoded_data_size < 0, it seems they are overflows */
1578 if (decoded_data_size <= 0) {1578 if (!got_output) {
1579 /* no audio frame */1579 /* no audio frame */
1580 continue;1580 continue;
1581 }1581 }
@@ -1592,11 +1592,11 @@ static int output_packet(AVInputStream *ist, int ist_index, · 10 unmodified lines
1592 pkt_pts = AV_NOPTS_VALUE;1592 pkt_pts = AV_NOPTS_VALUE;
1593 1593
1594 ret = avcodec_decode_video2(ist->st->codec,1594 ret = avcodec_decode_video2(ist->st->codec,
1595 &picture, &got_picture, &avpkt);1595 &picture, &got_output, &avpkt);
1596 ist->st->quality= picture.quality;1596 ist->st->quality= picture.quality;
1597 if (ret < 0)1597 if (ret < 0)
1598 goto fail_decode;1598 goto fail_decode;
1599 if (!got_picture) {1599 if (!got_output) {
1600 /* no picture yet */1600 /* no picture yet */
1601 goto discard_packet;1601 goto discard_packet;
1602 }1602 }
@@ -1613,10 +1613,10 @@ static int output_packet(AVInputStream *ist, int ist_index, · 10 unmodified lines
1613 break;1613 break;
1614 case AVMEDIA_TYPE_SUBTITLE:1614 case AVMEDIA_TYPE_SUBTITLE:
1615 ret = avcodec_decode_subtitle2(ist->st->codec,1615 ret = avcodec_decode_subtitle2(ist->st->codec,
1616 &subtitle, &got_picture, &avpkt);1616 &subtitle, &got_output, &avpkt);
1617 if (ret < 0)1617 if (ret < 0)
1618 goto fail_decode;1618 goto fail_decode;
1619 if (!got_picture) {1619 if (!got_output) {
1620 goto discard_packet;1620 goto discard_packet;
1621 }1621 }
1622 subtitle_to_free = &subtitle;1622 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
146 s->min_prediction_order,146 s->min_prediction_order,
147 s->max_prediction_order,147 s->max_prediction_order,
148 ALAC_MAX_LPC_PRECISION, coefs, shift,148 ALAC_MAX_LPC_PRECISION, coefs, shift,
149 AV_LPC_TYPE_LEVINSON, 0,149 FF_LPC_TYPE_LEVINSON, 0,
150 ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);150 ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
151 151
152 s->lpc[ch].lpc_order = opt_order;152 s->lpc[ch].lpc_order = opt_order;
@@ -457,7 +457,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx) · 304 unmodified lines
457 457
458 s->avctx = avctx;458 s->avctx = avctx;
459 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,459 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size, s->max_prediction_order,
460 AV_LPC_TYPE_LEVINSON);460 FF_LPC_TYPE_LEVINSON);
461 461
462 return ret;462 return ret;
463}463}
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
270 270
271void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)271void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
272{272{
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;
274 274
275 if (!h264_high_depth) {275 if (!high_bit_depth) {
276 c->put_pixels_tab[0][0] = put_pixels16_axp_asm;276 c->put_pixels_tab[0][0] = put_pixels16_axp_asm;
277 c->put_pixels_tab[0][1] = put_pixels16_x2_axp;277 c->put_pixels_tab[0][1] = put_pixels16_x2_axp;
278 c->put_pixels_tab[0][2] = put_pixels16_y2_axp;278 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
75 75
76void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)76void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
77{77{
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;
79 79
80 ff_put_pixels_clamped = c->put_pixels_clamped;80 ff_put_pixels_clamped = c->put_pixels_clamped;
81 ff_add_pixels_clamped = c->add_pixels_clamped;81 ff_add_pixels_clamped = c->add_pixels_clamped;
@@ -97,7 +97,7 @@ void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx) · 15 unmodified lines
97 97
98 c->add_pixels_clamped = ff_add_pixels_clamped_arm;98 c->add_pixels_clamped = ff_add_pixels_clamped_arm;
99 99
100 if (!h264_high_depth) {100 if (!high_bit_depth) {
101 c->put_pixels_tab[0][0] = ff_put_pixels16_arm;101 c->put_pixels_tab[0][0] = ff_put_pixels16_arm;
102 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_arm;102 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_arm;
103 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_arm;103 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
72 72
73void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)73void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)
74{74{
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;
76 76
77 if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||77 if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||
78 avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {78 avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {
@@ -82,7 +82,7 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx) · 3 unmodified lines
82 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;82 c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
83 }83 }
84 84
85 if (!h264_high_depth) {85 if (!high_bit_depth) {
86 c->put_pixels_tab[0][0] = ff_put_pixels16_armv6;86 c->put_pixels_tab[0][0] = ff_put_pixels16_armv6;
87 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6;87 c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6;
88 c->put_pixels_tab[0][2] = ff_put_pixels16_y2_armv6;88 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
173 173
174void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)174void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
175{175{
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;
177 177
178 if (!avctx->lowres) {178 if (!avctx->lowres) {
179 if (avctx->idct_algo == FF_IDCT_AUTO ||179 if (avctx->idct_algo == FF_IDCT_AUTO ||
@@ -192,7 +192,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) · 12 unmodified lines
192 }192 }
193 }193 }
194 194
195 if (!h264_high_depth) {195 if (!high_bit_depth) {
196 c->clear_block = ff_clear_block_neon;196 c->clear_block = ff_clear_block_neon;
197 c->clear_blocks = ff_clear_blocks_neon;197 c->clear_blocks = ff_clear_blocks_neon;
198 198
@@ -223,7 +223,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) · 24 unmodified lines
223 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon;223 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon;
224 224
225 if (CONFIG_H264_DECODER) {225 if (CONFIG_H264_DECODER) {
226 if (!h264_high_depth) {226 if (!high_bit_depth) {
227 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon;227 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_neon;
228 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon;228 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_neon;
229 c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_neon;229 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
155void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx)155void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx)
156{156{
157 int mm_flags = AV_CPU_FLAG_IWMMXT; /* multimedia extension flags */157 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;
159 159
160 if (avctx->dsp_mask) {160 if (avctx->dsp_mask) {
161 if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)161 if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
@@ -168,7 +168,7 @@ void ff_dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx) · 6 unmodified lines
168 168
169 c->add_pixels_clamped = add_pixels_clamped_iwmmxt;169 c->add_pixels_clamped = add_pixels_clamped_iwmmxt;
170 170
171 if (!h264_high_depth) {171 if (!high_bit_depth) {
172 c->clear_blocks = clear_blocks_iwmmxt;172 c->clear_blocks = clear_blocks_iwmmxt;
173 173
174 c->put_pixels_tab[0][0] = put_pixels16_iwmmxt;174 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
74 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon;74 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon;
75}75}
76 76
77void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth)77void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth)
78{78{
79 if (HAVE_NEON) ff_h264_pred_init_neon(h, codec_id, bit_depth);79 if (HAVE_NEON) ff_h264_pred_init_neon(h, codec_id, bit_depth);
80}80}
libavcodec/avcodec.h+25−10
@@ -516,10 +516,11 @@ enum AVChromaLocation{ · 515 unmodified lines
516 AVCHROMA_LOC_NB , ///< Not part of ABI516 AVCHROMA_LOC_NB , ///< Not part of ABI
517};517};
518 518
519#if FF_API_FLAC_GLOBAL_OPTS
519/**520/**
520 * LPC analysis type521 * LPC analysis type
521 */522 */
522enum AVLPCType {523attribute_deprecated enum AVLPCType {
523 AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type524 AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
524 AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients525 AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
525 AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients526 AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
@@ -527,6 +528,7 @@ enum AVLPCType { · 1 unmodified line
527 AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization528 AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
528 AV_LPC_TYPE_NB , ///< Not part of ABI529 AV_LPC_TYPE_NB , ///< Not part of ABI
529};530};
531#endif
530 532
531enum AVAudioServiceType {533enum AVAudioServiceType {
532 AV_AUDIO_SERVICE_TYPE_MAIN = 0,534 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
@@ -2514,42 +2516,53 @@ typedef struct AVCodecContext { · 1981 unmodified lines
2514#define FF_COMPRESSION_DEFAULT -12516#define FF_COMPRESSION_DEFAULT -1
2515 2517
2516 /**2518 /**
2517 * LPC coefficient precision - used by FLAC encoder
2518 * - encoding: Set by user.2519 * - encoding: Set by user.
2519 * - decoding: unused2520 * - decoding: unused
2520 */2521 */
2521 int lpc_coeff_precision;2522 int min_prediction_order;
2522 2523
2523 /**2524 /**
2524 * - encoding: Set by user.2525 * - encoding: Set by user.
2525 * - decoding: unused2526 * - decoding: unused
2526 */2527 */
2527 int min_prediction_order;2528 int max_prediction_order;
2528 2529
2530#if FF_API_FLAC_GLOBAL_OPTS
2529 /**2531 /**
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
2530 * - encoding: Set by user.2539 * - encoding: Set by user.
2531 * - decoding: unused2540 * - decoding: unused
2532 */2541 */
2533 int max_prediction_order;2542 attribute_deprecated int lpc_coeff_precision;
2534 2543
2535 /**2544 /**
2536 * search method for selecting prediction order2545 * search method for selecting prediction order
2537 * - encoding: Set by user.2546 * - encoding: Set by user.
2538 * - decoding: unused2547 * - decoding: unused
2539 */2548 */
2540 int prediction_order_method;2549 attribute_deprecated int prediction_order_method;
2541 2550
2542 /**2551 /**
2543 * - encoding: Set by user.2552 * - encoding: Set by user.
2544 * - decoding: unused2553 * - decoding: unused
2545 */2554 */
2546 int min_partition_order;2555 attribute_deprecated int min_partition_order;
2547 2556
2548 /**2557 /**
2549 * - encoding: Set by user.2558 * - encoding: Set by user.
2550 * - decoding: unused2559 * - decoding: unused
2551 */2560 */
2552 int max_partition_order;2561 attribute_deprecated int max_partition_order;
2562 /**
2563 * @}
2564 */
2565#endif
2553 2566
2554 /**2567 /**
2555 * GOP timecode frame start number, in non drop frame format2568 * GOP timecode frame start number, in non drop frame format
@@ -2767,19 +2780,21 @@ typedef struct AVCodecContext { · 211 unmodified lines
2767 2780
2768 int log_level_offset;2781 int log_level_offset;
2769 2782
2783#if FF_API_FLAC_GLOBAL_OPTS
2770 /**2784 /**
2771 * Determines which LPC analysis algorithm to use.2785 * Determines which LPC analysis algorithm to use.
2772 * - encoding: Set by user2786 * - encoding: Set by user
2773 * - decoding: unused2787 * - decoding: unused
2774 */2788 */
2775 enum AVLPCType lpc_type;2789 attribute_deprecated enum AVLPCType lpc_type;
2776 2790
2777 /**2791 /**
2778 * Number of passes to use for Cholesky factorization during LPC analysis2792 * Number of passes to use for Cholesky factorization during LPC analysis
2779 * - encoding: Set by user2793 * - encoding: Set by user
2780 * - decoding: unused2794 * - decoding: unused
2781 */2795 */
2782 int lpc_passes;2796 attribute_deprecated int lpc_passes;
2797#endif
2783 2798
2784 /**2799 /**
2785 * Number of slices.2800 * 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
197 197
198void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )198void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
199{199{
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;
201 201
202 c->get_pixels = ff_bfin_get_pixels;202 c->get_pixels = ff_bfin_get_pixels;
203 c->diff_pixels = ff_bfin_diff_pixels;203 c->diff_pixels = ff_bfin_diff_pixels;
204 c->put_pixels_clamped = ff_bfin_put_pixels_clamped;204 c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
205 c->add_pixels_clamped = ff_bfin_add_pixels_clamped;205 c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
206 206
207 if (!h264_high_depth)207 if (!high_bit_depth)
208 c->clear_blocks = bfin_clear_blocks;208 c->clear_blocks = bfin_clear_blocks;
209 c->pix_sum = ff_bfin_pix_sum;209 c->pix_sum = ff_bfin_pix_sum;
210 c->pix_norm1 = ff_bfin_pix_norm1;210 c->pix_norm1 = ff_bfin_pix_norm1;
@@ -231,7 +231,7 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) · 20 unmodified lines
231 c->sse[1] = ff_bfin_sse8;231 c->sse[1] = ff_bfin_sse8;
232 c->sse[2] = ff_bfin_sse4;232 c->sse[2] = ff_bfin_sse4;
233 233
234 if (!h264_high_depth) {234 if (!high_bit_depth) {
235 c->put_pixels_tab[0][0] = bfin_put_pixels16;235 c->put_pixels_tab[0][0] = bfin_put_pixels16;
236 c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;236 c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
237 c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;237 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
43uint32_t ff_squareTbl[512] = {0, };43uint32_t ff_squareTbl[512] = {0, };
44 44
45#define BIT_DEPTH 945#define BIT_DEPTH 9
46#include "dsputil_internal.h"46#include "dsputil_template.c"
47#undef BIT_DEPTH47#undef BIT_DEPTH
48 48
49#define BIT_DEPTH 1049#define BIT_DEPTH 10
50#include "dsputil_internal.h"50#include "dsputil_template.c"
51#undef BIT_DEPTH51#undef BIT_DEPTH
52 52
53#define BIT_DEPTH 853#define BIT_DEPTH 8
54#include "dsputil_internal.h"54#include "dsputil_template.c"
55 55
56// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size56// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
57#define pb_7f (~0UL/255 * 0x7f)57#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
32static 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
43static 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
54static 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
66static 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
82static 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 */
128void 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
195static 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
216static 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) \
236static 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\
246static 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\
258static 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\
270static 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\
282static 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\
294static 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\
330static 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\
366CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels_c , 8*sizeof(pixel))\
367CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8*sizeof(pixel))\
368CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8*sizeof(pixel))\
369CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8*sizeof(pixel))\
370CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8*sizeof(pixel))\
371CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8*sizeof(pixel))\
372CALL_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) \
378static 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}\
386static 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}\
394static 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}\
403static 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\
407static 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\
421static 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\
435static 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\
446static 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\
457static 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\
463static 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\
469static 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\
473static 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\
477static 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\
481static 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\
485static 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\
522static 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\
526static 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\
530static 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\
534static 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\
538static 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}\
574static 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}\
579static 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\
585static 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\
621static 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\
658static 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\
700static 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\
742CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
743CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_x2) , FUNCC(OPNAME ## _pixels8_x2) , 8*sizeof(pixel))\
744CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_y2) , FUNCC(OPNAME ## _pixels8_y2) , 8*sizeof(pixel))\
745CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
746av_unused CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16) , FUNCC(OPNAME ## _pixels8) , 8*sizeof(pixel))\
747CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_x2) , FUNCC(OPNAME ## _no_rnd_pixels8_x2) , 8*sizeof(pixel))\
748CALL_2X_PIXELS(FUNCC(OPNAME ## _no_rnd_pixels16_y2) , FUNCC(OPNAME ## _no_rnd_pixels8_y2) , 8*sizeof(pixel))\
749CALL_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
755PIXOP2(avg, op_avg)
756PIXOP2(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
763static 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
767static 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)\
772static 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\
803static 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\
838static 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
884H264_CHROMA_MC(put_ , op_put)
885H264_CHROMA_MC(avg_ , op_avg)
886#undef op_avg
887#undef op_put
888
889#define H264_LOWPASS(OPNAME, OP, OP2) \
890static 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\
907static 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\
931static 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}\
965static 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\
984static 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\
1012static 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\
1053static 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\
1076static 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\
1112static 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\
1165static 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\
1174static 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\
1183static 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) \
1193static 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\
1197static 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\
1203static 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\
1207static 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\
1213static 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\
1222static 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\
1229static 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\
1238static 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\
1249static 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\
1260static 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\
1271static 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\
1282static 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\
1287static 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\
1296static 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\
1305static 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\
1317static 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
1335H264_LOWPASS(put_ , op_put, op2_put)
1336H264_LOWPASS(avg_ , op_avg, op2_avg)
1337H264_MC(put_, 2)
1338H264_MC(put_, 4)
1339H264_MC(put_, 8)
1340H264_MC(put_, 16)
1341H264_MC(avg_, 4)
1342H264_MC(avg_, 8)
1343H264_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
1367void FUNCC(ff_put_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1368 FUNCC(put_pixels8)(dst, src, stride, 8);
1369}
1370void FUNCC(ff_avg_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
1371 FUNCC(avg_pixels8)(dst, src, stride, 8);
1372}
1373void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1374 FUNCC(put_pixels16)(dst, src, stride, 16);
1375}
1376void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
1377 FUNCC(avg_pixels16)(dst, src, stride, 16);
1378}
1379
1380static 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 */
1388static 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
21 21
22#include "libavutil/crc.h"22#include "libavutil/crc.h"
23#include "libavutil/md5.h"23#include "libavutil/md5.h"
24#include "libavutil/opt.h"
24#include "avcodec.h"25#include "avcodec.h"
25#include "get_bits.h"26#include "get_bits.h"
26#include "golomb.h"27#include "golomb.h"
@@ -43,7 +44,7 @@ · 16 unmodified lines
43typedef struct CompressionOptions {44typedef struct CompressionOptions {
44 int compression_level;45 int compression_level;
45 int block_time_ms;46 int block_time_ms;
46 enum AVLPCType lpc_type;47 enum FFLPCType lpc_type;
47 int lpc_passes;48 int lpc_passes;
48 int lpc_coeff_precision;49 int lpc_coeff_precision;
49 int min_prediction_order;50 int min_prediction_order;
@@ -80,6 +81,7 @@ typedef struct FlacFrame { · 30 unmodified lines
80} FlacFrame;81} FlacFrame;
81 82
82typedef struct FlacEncodeContext {83typedef struct FlacEncodeContext {
84 AVClass *class;
83 PutBitContext pb;85 PutBitContext pb;
84 int channels;86 int channels;
85 int samplerate;87 int samplerate;
@@ -156,16 +158,16 @@ static av_cold void dprint_compression_options(FlacEncodeContext *s) · 70 unmodified lines
156 av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);158 av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", opt->compression_level);
157 159
158 switch (opt->lpc_type) {160 switch (opt->lpc_type) {
159 case AV_LPC_TYPE_NONE:161 case FF_LPC_TYPE_NONE:
160 av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n");162 av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n");
161 break;163 break;
162 case AV_LPC_TYPE_FIXED:164 case FF_LPC_TYPE_FIXED:
163 av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n");165 av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n");
164 break;166 break;
165 case AV_LPC_TYPE_LEVINSON:167 case FF_LPC_TYPE_LEVINSON:
166 av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n");168 av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n");
167 break;169 break;
168 case AV_LPC_TYPE_CHOLESKY:170 case FF_LPC_TYPE_CHOLESKY:
169 av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n",171 av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n",
170 opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");172 opt->lpc_passes, opt->lpc_passes == 1 ? "" : "es");
171 break;173 break;
@@ -266,32 +268,42 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 94 unmodified lines
266 268
267 s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level];269 s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level];
268 270
269 s->options.lpc_type = ((int[]){ AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED,271 if (s->options.lpc_type == FF_LPC_TYPE_DEFAULT)
270 AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,272 s->options.lpc_type = ((int[]){ FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED, FF_LPC_TYPE_FIXED,
271 AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,273 FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
272 AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON,274 FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
273 AV_LPC_TYPE_LEVINSON})[level];275 FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON, FF_LPC_TYPE_LEVINSON,
276 FF_LPC_TYPE_LEVINSON})[level];
274 277
275 s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level];278 s->options.min_prediction_order = ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level];
276 s->options.max_prediction_order = ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level];279 s->options.max_prediction_order = ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level];
277 280
278 s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,281 if (s->options.prediction_order_method < 0)
279 ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,282 s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
280 ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,283 ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST,
281 ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,284 ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL,
282 ORDER_METHOD_SEARCH})[level];285 ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG,
286 ORDER_METHOD_SEARCH})[level];
283 287
284 s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level];288 if (s->options.min_partition_order > s->options.max_partition_order) {
285 s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];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];
286 297
287 /* set compression option overrides from AVCodecContext */298 /* set compression option overrides from AVCodecContext */
288 if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) {299#if FF_API_FLAC_GLOBAL_OPTS
289 if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) {300 if (avctx->lpc_type > FF_LPC_TYPE_DEFAULT) {
301 if (avctx->lpc_type > FF_LPC_TYPE_CHOLESKY) {
290 av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);302 av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type);
291 return -1;303 return -1;
292 }304 }
293 s->options.lpc_type = avctx->lpc_type;305 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) {
295 if (avctx->lpc_passes < 0) {307 if (avctx->lpc_passes < 0) {
296 // default number of passes for Cholesky308 // default number of passes for Cholesky
297 s->options.lpc_passes = 2;309 s->options.lpc_passes = 2;
@@ -304,11 +316,12 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 6 unmodified lines
304 }316 }
305 }317 }
306 }318 }
319#endif
307 320
308 if (s->options.lpc_type == AV_LPC_TYPE_NONE) {321 if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
309 s->options.min_prediction_order = 0;322 s->options.min_prediction_order = 0;
310 } else if (avctx->min_prediction_order >= 0) {323 } 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) {
312 if (avctx->min_prediction_order > MAX_FIXED_ORDER) {325 if (avctx->min_prediction_order > MAX_FIXED_ORDER) {
313 av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",326 av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
314 avctx->min_prediction_order);327 avctx->min_prediction_order);
@@ -322,10 +335,10 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
322 }335 }
323 s->options.min_prediction_order = avctx->min_prediction_order;336 s->options.min_prediction_order = avctx->min_prediction_order;
324 }337 }
325 if (s->options.lpc_type == AV_LPC_TYPE_NONE) {338 if (s->options.lpc_type == FF_LPC_TYPE_NONE) {
326 s->options.max_prediction_order = 0;339 s->options.max_prediction_order = 0;
327 } else if (avctx->max_prediction_order >= 0) {340 } 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) {
329 if (avctx->max_prediction_order > MAX_FIXED_ORDER) {342 if (avctx->max_prediction_order > MAX_FIXED_ORDER) {
330 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",343 av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
331 avctx->max_prediction_order);344 avctx->max_prediction_order);
@@ -345,6 +358,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 13 unmodified lines
345 return -1;358 return -1;
346 }359 }
347 360
361#if FF_API_FLAC_GLOBAL_OPTS
348 if (avctx->prediction_order_method >= 0) {362 if (avctx->prediction_order_method >= 0) {
349 if (avctx->prediction_order_method > ORDER_METHOD_LOG) {363 if (avctx->prediction_order_method > ORDER_METHOD_LOG) {
350 av_log(avctx, AV_LOG_ERROR, "invalid prediction order method: %d\n",364 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
375 s->options.min_partition_order, s->options.max_partition_order);389 s->options.min_partition_order, s->options.max_partition_order);
376 return -1;390 return -1;
377 }391 }
392#endif
378 393
379 if (avctx->frame_size > 0) {394 if (avctx->frame_size > 0) {
380 if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||395 if (avctx->frame_size < FLAC_MIN_BLOCKSIZE ||
@@ -388,6 +403,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 7 unmodified lines
388 }403 }
389 s->max_blocksize = s->avctx->frame_size;404 s->max_blocksize = s->avctx->frame_size;
390 405
406#if FF_API_FLAC_GLOBAL_OPTS
391 /* set LPC precision */407 /* set LPC precision */
392 if (avctx->lpc_coeff_precision > 0) {408 if (avctx->lpc_coeff_precision > 0) {
393 if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {409 if (avctx->lpc_coeff_precision > MAX_LPC_PRECISION) {
@@ -396,10 +412,8 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 2 unmodified lines
396 return -1;412 return -1;
397 }413 }
398 s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;414 s->options.lpc_coeff_precision = avctx->lpc_coeff_precision;
399 } else {
400 /* default LPC precision */
401 s->options.lpc_coeff_precision = 15;
402 }415 }
416#endif
403 417
404 /* set maximum encoded frame size in verbatim mode */418 /* set maximum encoded frame size in verbatim mode */
405 s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size,419 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
448 }462 }
449 463
450 ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,464 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);
452 466
453 dprint_compression_options(s);467 dprint_compression_options(s);
454 468
@@ -889,8 +903,8 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch) · 434 unmodified lines
889 903
890 /* FIXED */904 /* FIXED */
891 sub->type = FLAC_SUBFRAME_FIXED;905 sub->type = FLAC_SUBFRAME_FIXED;
892 if (s->options.lpc_type == AV_LPC_TYPE_NONE ||906 if (s->options.lpc_type == FF_LPC_TYPE_NONE ||
893 s->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) {907 s->options.lpc_type == FF_LPC_TYPE_FIXED || n <= max_order) {
894 uint32_t bits[MAX_FIXED_ORDER+1];908 uint32_t bits[MAX_FIXED_ORDER+1];
895 if (max_order > MAX_FIXED_ORDER)909 if (max_order > MAX_FIXED_ORDER)
896 max_order = MAX_FIXED_ORDER;910 max_order = MAX_FIXED_ORDER;
@@ -1336,6 +1350,33 @@ static av_cold int flac_encode_close(AVCodecContext *avctx) · 439 unmodified lines
1336 return 0;1350 return 0;
1337}1351}
1338 1352
1353#define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
1354static 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
1374static const AVClass flac_encoder_class = {
1375 "FLAC encoder",
1376 av_default_item_name,
1377 options,
1378 LIBAVUTIL_VERSION_INT,
1379};
1339 1380
1340AVCodec ff_flac_encoder = {1381AVCodec ff_flac_encoder = {
1341 "flac",1382 "flac",
@@ -1349,4 +1390,5 @@ AVCodec ff_flac_encoder = { · 7 unmodified lines
1349 .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,1390 .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
1350 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},1391 .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
1351 .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),1392 .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
1393 .priv_class = &flac_encoder_class,
1352};1394};
libavcodec/h264.c+73−62
@@ -45,11 +45,11 @@ · 44 unmodified lines
45//#undef NDEBUG45//#undef NDEBUG
46#include <assert.h>46#include <assert.h>
47 47
48static const uint8_t rem6[QP_MAX_MAX+1]={48static const uint8_t rem6[QP_MAX_NUM+1]={
490, 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,490, 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,
50};50};
51 51
52static const uint8_t div6[QP_MAX_MAX+1]={52static const uint8_t div6[QP_MAX_NUM+1]={
530, 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,530, 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,
54};54};
55 55
@@ -586,6 +586,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){ · 530 unmodified lines
586 586
587 h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;587 h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
588 h->pixel_shift = 0;588 h->pixel_shift = 0;
589 h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
589 590
590 h->thread_context[0] = h;591 h->thread_context[0] = h;
591 h->outputed_poc = h->next_outputed_poc = INT_MIN;592 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
733int ff_h264_frame_start(H264Context *h){734int ff_h264_frame_start(H264Context *h){
734 MpegEncContext * const s = &h->s;735 MpegEncContext * const s = &h->s;
735 int i;736 int i;
737 const int pixel_shift = h->pixel_shift;
736 738
737 if(MPV_frame_start(s, s->avctx) < 0)739 if(MPV_frame_start(s, s->avctx) < 0)
738 return -1;740 return -1;
@@ -749,14 +751,14 @@ int ff_h264_frame_start(H264Context *h){ · 10 unmodified lines
749 assert(s->linesize && s->uvlinesize);751 assert(s->linesize && s->uvlinesize);
750 752
751 for(i=0; i<16; i++){753 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);754 h->block_offset[i]= (4*((scan8[i] - scan8[0])&7) << 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);755 h->block_offset[24+i]= (4*((scan8[i] - scan8[0])&7) << pixel_shift) + 8*s->linesize*((scan8[i] - scan8[0])>>3);
754 }756 }
755 for(i=0; i<4; i++){757 for(i=0; i<4; i++){
756 h->block_offset[16+i]=758 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);
758 h->block_offset[24+16+i]=760 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);
760 }762 }
761 763
762 /* can't be in alloc_tables because linesize isn't known there.764 /* 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
948 MpegEncContext * const s = &h->s;950 MpegEncContext * const s = &h->s;
949 uint8_t *top_border;951 uint8_t *top_border;
950 int top_idx = 1;952 int top_idx = 1;
953 const int pixel_shift = h->pixel_shift;
951 954
952 src_y -= linesize;955 src_y -= linesize;
953 src_cb -= uvlinesize;956 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
958 if(!MB_MBAFF){961 if(!MB_MBAFF){
959 top_border = h->top_borders[0][s->mb_x];962 top_border = h->top_borders[0][s->mb_x];
960 AV_COPY128(top_border, src_y + 15*linesize);963 AV_COPY128(top_border, src_y + 15*linesize);
961 if (h->pixel_shift)964 if (pixel_shift)
962 AV_COPY128(top_border+16, src_y+15*linesize+16);965 AV_COPY128(top_border+16, src_y+15*linesize+16);
963 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){966 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
964 if (h->pixel_shift) {967 if (pixel_shift) {
965 AV_COPY128(top_border+32, src_cb+7*uvlinesize);968 AV_COPY128(top_border+32, src_cb+7*uvlinesize);
966 AV_COPY128(top_border+48, src_cr+7*uvlinesize);969 AV_COPY128(top_border+48, src_cr+7*uvlinesize);
967 } else {970 } else {
@@ -980,11 +983,11 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src · 12 unmodified lines
980 // There are two lines saved, the line above the the top macroblock of a pair,983 // There are two lines saved, the line above the the top macroblock of a pair,
981 // and the line above the bottom macroblock984 // and the line above the bottom macroblock
982 AV_COPY128(top_border, src_y + 16*linesize);985 AV_COPY128(top_border, src_y + 16*linesize);
983 if (h->pixel_shift)986 if (pixel_shift)
984 AV_COPY128(top_border+16, src_y+16*linesize+16);987 AV_COPY128(top_border+16, src_y+16*linesize+16);
985 988
986 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){989 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
987 if (h->pixel_shift) {990 if (pixel_shift) {
988 AV_COPY128(top_border+32, src_cb+8*uvlinesize);991 AV_COPY128(top_border+32, src_cb+8*uvlinesize);
989 AV_COPY128(top_border+48, src_cr+8*uvlinesize);992 AV_COPY128(top_border+48, src_cr+8*uvlinesize);
990 } else {993 } else {
@@ -994,7 +997,10 @@ static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src · 3 unmodified lines
994 }997 }
995}998}
996 999
997static 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){1000static 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){
998 MpegEncContext * const s = &h->s;1004 MpegEncContext * const s = &h->s;
999 int deblock_left;1005 int deblock_left;
1000 int deblock_top;1006 int deblock_top;
@@ -1040,38 +1046,38 @@ else AV_COPY64(b,a); · 39 unmodified lines
1040 1046
1041 if(deblock_top){1047 if(deblock_top){
1042 if(deblock_left){1048 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);
1044 }1050 }
1045 XCHG(top_border+(0<<pixel_shift), src_y +(1<<pixel_shift), xchg);1051 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);1052 XCHG(top_border + (8 << pixel_shift), src_y + (9 << pixel_shift), 1);
1047 if(s->mb_x+1 < s->mb_width){1053 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);
1049 }1055 }
1050 }1056 }
1051 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){1057 if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
1052 if(deblock_top){1058 if(deblock_top){
1053 if(deblock_left){1059 if(deblock_left){
1054 XCHG(top_border_m1+(16<<pixel_shift), src_cb -(7<<pixel_shift), 1);1060 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);1061 XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
1056 }1062 }
1057 XCHG(top_border+(16<<pixel_shift), src_cb+1+pixel_shift, 1);1063 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);1064 XCHG(top_border + (24 << pixel_shift), src_cr+1+pixel_shift, 1);
1059 }1065 }
1060 }1066 }
1061}1067}
1062 1068
1063static av_always_inline int dctcoef_get(H264Context *h, DCTELEM *mb, int index, int pixel_shift) {1069static av_always_inline int dctcoef_get(DCTELEM *mb, int high_bit_depth, int index) {
1064 if (!pixel_shift)1070 if (high_bit_depth) {
1065 return mb[index];1071 return AV_RN32A(((int32_t*)mb) + index);
1066 else1072 } else
1067 return ((int32_t*)mb)[index];1073 return AV_RN16A(mb + index);
1068}1074}
1069 1075
1070static av_always_inline void dctcoef_set(H264Context *h, DCTELEM *mb, int index, int value, int pixel_shift) {1076static av_always_inline void dctcoef_set(DCTELEM *mb, int high_bit_depth, int index, int value) {
1071 if (!pixel_shift)1077 if (high_bit_depth) {
1072 mb[index] = value;1078 AV_WN32A(((int32_t*)mb) + index, value);
1073 else1079 } else
1074 ((int32_t*)mb)[index] = value;1080 AV_WN16A(mb + index, value);
1075}1081}
1076 1082
1077static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, int pixel_shift){1083static 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
1090 void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);1096 void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
1091 void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);1097 void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
1092 1098
1093 dest_y = s->current_picture.data[0] + ((mb_x<<pixel_shift) + mb_y * s->linesize ) * 16;1099 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;1100 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;1101 dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
1096 1102
1097 s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64<<pixel_shift), s->linesize, 4);1103 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);1104 s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + (64 << pixel_shift), dest_cr - dest_cb, 2);
1099 1105
1100 h->list_counts[mb_xy]= h->list_count;1106 h->list_counts[mb_xy]= h->list_count;
1101 1107
@@ -1186,16 +1192,16 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 84 unmodified lines
1186 uint8_t * const ptr= dest_y + block_offset[i];1192 uint8_t * const ptr= dest_y + block_offset[i];
1187 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];1193 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
1188 if(transform_bypass && h->sps.profile_idc==244 && dir<=1){1194 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);
1190 }else{1196 }else{
1191 const int nnz = h->non_zero_count_cache[ scan8[i] ];1197 const int nnz = h->non_zero_count_cache[ scan8[i] ];
1192 h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,1198 h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,
1193 (h->topright_samples_available<<i)&0x4000, linesize);1199 (h->topright_samples_available<<i)&0x4000, linesize);
1194 if(nnz){1200 if(nnz){
1195 if(nnz == 1 && dctcoef_get(h, h->mb, i*16, pixel_shift))1201 if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16))
1196 idct_dc_add(ptr, h->mb + (i*16<<pixel_shift), linesize);1202 idct_dc_add(ptr, h->mb + (i*16 << pixel_shift), linesize);
1197 else1203 else
1198 idct_add (ptr, h->mb + (i*16<<pixel_shift), linesize);1204 idct_add (ptr, h->mb + (i*16 << pixel_shift), linesize);
1199 }1205 }
1200 }1206 }
1201 }1207 }
@@ -1212,7 +1218,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 10 unmodified lines
1212 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];1218 const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
1213 1219
1214 if(transform_bypass && h->sps.profile_idc==244 && dir<=1){1220 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);
1216 }else{1222 }else{
1217 uint8_t *topright;1223 uint8_t *topright;
1218 int nnz, tr;1224 int nnz, tr;
@@ -1229,7 +1235,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 10 unmodified lines
1229 topright= (uint8_t*) &tr;1235 topright= (uint8_t*) &tr;
1230 }1236 }
1231 }else1237 }else
1232 topright= ptr + (4<<pixel_shift) - linesize;1238 topright= ptr + (4 << pixel_shift) - linesize;
1233 }else1239 }else
1234 topright= NULL;1240 topright= NULL;
1235 1241
@@ -1237,8 +1243,8 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 1 unmodified line
1237 nnz = h->non_zero_count_cache[ scan8[i] ];1243 nnz = h->non_zero_count_cache[ scan8[i] ];
1238 if(nnz){1244 if(nnz){
1239 if(is_h264){1245 if(is_h264){
1240 if(nnz == 1 && dctcoef_get(h, h->mb, i*16, pixel_shift))1246 if(nnz == 1 && dctcoef_get(h->mb, pixel_shift, i*16))
1241 idct_dc_add(ptr, h->mb + (i*16<<pixel_shift), linesize);1247 idct_dc_add(ptr, h->mb + (i*16 << pixel_shift), linesize);
1242 else1248 else
1243 idct_add (ptr, h->mb + (i*16<<pixel_shift), linesize);1249 idct_add (ptr, h->mb + (i*16<<pixel_shift), linesize);
1244 }1250 }
@@ -1261,7 +1267,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 16 unmodified lines
1261 static const uint8_t dc_mapping[16] = { 0*16, 1*16, 4*16, 5*16, 2*16, 3*16, 6*16, 7*16,1267 static const uint8_t dc_mapping[16] = { 0*16, 1*16, 4*16, 5*16, 2*16, 3*16, 6*16, 7*16,
1262 8*16, 9*16,12*16,13*16,10*16,11*16,14*16,15*16};1268 8*16, 9*16,12*16,13*16,10*16,11*16,14*16,15*16};
1263 for(i = 0; i < 16; i++)1269 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));
1265 }1271 }
1266 }1272 }
1267 }1273 }
@@ -1288,8 +1294,8 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 20 unmodified lines
1288 h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb, linesize);1294 h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb, linesize);
1289 }else{1295 }else{
1290 for(i=0; i<16; i++){1296 for(i=0; i<16; i++){
1291 if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h, h->mb, i*16,pixel_shift))1297 if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16))
1292 s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + (i*16<<pixel_shift), linesize);1298 s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + (i*16 << pixel_shift), linesize);
1293 }1299 }
1294 }1300 }
1295 }else{1301 }else{
@@ -1301,7 +1307,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 5 unmodified lines
1301 idct_add= IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4;1307 idct_add= IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4;
1302 for(i=0; i<16; i+=di){1308 for(i=0; i<16; i+=di){
1303 if(h->non_zero_count_cache[ scan8[i] ]){1309 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);
1305 }1311 }
1306 }1312 }
1307 }else{1313 }else{
@@ -1329,21 +1335,21 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 21 unmodified lines
1329 uint8_t *dest[2] = {dest_cb, dest_cr};1335 uint8_t *dest[2] = {dest_cb, dest_cr};
1330 if(transform_bypass){1336 if(transform_bypass){
1331 if(IS_INTRA(mb_type) && h->sps.profile_idc==244 && (h->chroma_pred_mode==VERT_PRED8x8 || h->chroma_pred_mode==HOR_PRED8x8)){1337 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);1338 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);1339 h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 20, h->mb + (20*16 << pixel_shift), uvlinesize);
1334 }else{1340 }else{
1335 idct_add = s->dsp.add_pixels4;1341 idct_add = s->dsp.add_pixels4;
1336 for(i=16; i<16+8; i++){1342 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))1343 if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16))
1338 idct_add (dest[(i&4)>>2] + block_offset[i], h->mb + (i*16<<pixel_shift), uvlinesize);1344 idct_add (dest[(i&4)>>2] + block_offset[i], h->mb + (i*16 << pixel_shift), uvlinesize);
1339 }1345 }
1340 }1346 }
1341 }else{1347 }else{
1342 if(is_h264){1348 if(is_h264){
1343 if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ])1349 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]);
1345 if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ])1351 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]);
1347 h->h264dsp.h264_idct_add8(dest, block_offset,1353 h->h264dsp.h264_idct_add8(dest, block_offset,
1348 h->mb, uvlinesize,1354 h->mb, uvlinesize,
1349 h->non_zero_count_cache);1355 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
1370/**1376/**
1371 * Process a macroblock; this case avoids checks for expensive uncommon cases.1377 * Process a macroblock; this case avoids checks for expensive uncommon cases.
1372 */1378 */
1373static void hl_decode_mb_simple8(H264Context *h){1379#define hl_decode_mb_simple(sh, bits) \
1374 hl_decode_mb_internal(h, 1, 0);1380static void hl_decode_mb_simple_ ## bits(H264Context *h){ \
1381 hl_decode_mb_internal(h, 1, sh); \
1375}1382}
1383hl_decode_mb_simple(0, 8);
1384hl_decode_mb_simple(1, 16);
1376 1385
1377/**1386/**
1378 * Process a macroblock; this handles edge cases, such as interlacing.1387 * 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
1387 const int mb_type= s->current_picture.mb_type[mb_xy];1396 const int mb_type= s->current_picture.mb_type[mb_xy];
1388 int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;1397 int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;
1389 1398
1390 if (is_complex || h->pixel_shift)1399 if (is_complex) {
1391 hl_decode_mb_complex(h);1400 hl_decode_mb_complex(h);
1392 else{1401 } else if (h->pixel_shift) {
1393 hl_decode_mb_simple8(h);1402 hl_decode_mb_simple_16(h);
1394 }1403 } else
1404 hl_decode_mb_simple_8(h);
1395}1405}
1396 1406
1397static int pred_weight_table(H264Context *h){1407static int pred_weight_table(H264Context *h){
@@ -2557,6 +2567,7 @@ static void loop_filter(H264Context *h){ · 1159 unmodified lines
2557 const int end_mb_y= s->mb_y + FRAME_MBAFF;2567 const int end_mb_y= s->mb_y + FRAME_MBAFF;
2558 const int old_slice_type= h->slice_type;2568 const int old_slice_type= h->slice_type;
2559 const int end_mb_x = s->mb_x;2569 const int end_mb_x = s->mb_x;
2570 const int pixel_shift = h->pixel_shift;
2560 2571
2561 if(h->deblocking_filter) {2572 if(h->deblocking_filter) {
2562 int start_x= s->resync_mb_y == s->mb_y ? s->resync_mb_x : 0;2573 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
2573 2584
2574 s->mb_x= mb_x;2585 s->mb_x= mb_x;
2575 s->mb_y= mb_y;2586 s->mb_y= mb_y;
2576 dest_y = s->current_picture.data[0] + ((mb_x<<h->pixel_shift) + mb_y * s->linesize ) * 16;2587 dest_y = s->current_picture.data[0] + ((mb_x << 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;2588 dest_cb = s->current_picture.data[1] + ((mb_x << 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;2589 dest_cr = s->current_picture.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
2579 //FIXME simplify above2590 //FIXME simplify above
2580 2591
2581 if (MB_FIELD) {2592 if (MB_FIELD) {
@@ -3060,7 +3071,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ · 478 unmodified lines
3060 if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {3071 if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) {
3061 if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {3072 if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
3062 avctx->bits_per_raw_sample = h->sps.bit_depth_luma;3073 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;
3064 3075
3065 ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);3076 ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
3066 ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);3077 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
108 */108 */
109#define DELAYED_PIC_REF 4109#define DELAYED_PIC_REF 4
110 110
111#define QP_MAX_MAX (51 + 2*6) // The maximum supported qp111#define QP_MAX_NUM (51 + 2*6) // The maximum supported qp
112 112
113/* NAL unit types */113/* NAL unit types */
114enum {114enum {
@@ -266,7 +266,7 @@ typedef struct MMCO{ · 151 unmodified lines
266typedef struct H264Context{266typedef struct H264Context{
267 MpegEncContext s;267 MpegEncContext s;
268 H264DSPContext h264dsp;268 H264DSPContext h264dsp;
269 int pixel_shift;269 int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
270 int chroma_qp[2]; //QPc270 int chroma_qp[2]; //QPc
271 271
272 int qp_thresh; ///< QP threshold to skip loopfilter272 int qp_thresh; ///< QP threshold to skip loopfilter
@@ -355,8 +355,8 @@ typedef struct H264Context{ · 82 unmodified lines
355 */355 */
356 PPS pps; //FIXME move to Picture perhaps? (->no) do we need that?356 PPS pps; //FIXME move to Picture perhaps? (->no) do we need that?
357 357
358 uint32_t dequant4_buffer[6][QP_MAX_MAX+1][16]; //FIXME should these be moved down?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_MAX+1][64];359 uint32_t dequant8_buffer[2][QP_MAX_NUM+1][64];
360 uint32_t (*dequant4_coeff[6])[16];360 uint32_t (*dequant4_coeff[6])[16];
361 uint32_t (*dequant8_coeff[2])[64];361 uint32_t (*dequant8_coeff[2])[64];
362 362
@@ -597,7 +597,7 @@ typedef struct H264Context{ · 234 unmodified lines
597}H264Context;597}H264Context;
598 598
599 599
600extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_MAX+1]; ///< One chroma qp table for each supported bit depth (8, 9, 10).600extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM+1]; ///< One chroma qp table for each supported bit depth (8, 9, 10).
601 601
602/**602/**
603 * Decode SEI603 * 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
1103 1103
1104 1104
1105#define STORE_BLOCK(type) \1105#define STORE_BLOCK(type) \
1106 do {\1106 do { \
1107 uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base;\1107 uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base; \
1108\1108 \
1109 int j= scantable[index[--coeff_count]];\1109 int j= scantable[index[--coeff_count]]; \
1110 \
1110 if( get_cabac( CC, ctx ) == 0 ) { \1111 if( get_cabac( CC, ctx ) == 0 ) { \
1111 node_ctx = coeff_abs_level_transition[0][node_ctx]; \1112 node_ctx = coeff_abs_level_transition[0][node_ctx]; \
1112 if( is_dc ) { \1113 if( is_dc ) { \
@@ -1141,8 +1142,8 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 28 unmodified lines
1141 }else{ \1142 }else{ \
1142 ((type*)block)[j] = ((int)(get_cabac_bypass_sign( CC, -coeff_abs ) * qmul[j] + 32)) >> 6; \1143 ((type*)block)[j] = ((int)(get_cabac_bypass_sign( CC, -coeff_abs ) * qmul[j] + 32)) >> 6; \
1143 } \1144 } \
1144 }\1145 } \
1145 } while( coeff_count );1146 } while ( coeff_count );
1146 1147
1147 if (h->pixel_shift) {1148 if (h->pixel_shift) {
1148 STORE_BLOCK(int32_t)1149 STORE_BLOCK(int32_t)
@@ -1204,6 +1205,7 @@ int ff_h264_decode_mb_cabac(H264Context *h) { · 55 unmodified lines
1204 int mb_xy;1205 int mb_xy;
1205 int mb_type, partition_count, cbp = 0;1206 int mb_type, partition_count, cbp = 0;
1206 int dct8x8_allowed= h->pps.transform_8x8_mode;1207 int dct8x8_allowed= h->pps.transform_8x8_mode;
1208 const int pixel_shift = h->pixel_shift;
1207 1209
1208 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;1210 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
1209 1211
@@ -1312,7 +1314,7 @@ decode_intra_mb: · 102 unmodified lines
1312 h->slice_table[ mb_xy ]= h->slice_num;1314 h->slice_table[ mb_xy ]= h->slice_num;
1313 1315
1314 if(IS_INTRA_PCM(mb_type)) {1316 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;
1316 const uint8_t *ptr;1318 const uint8_t *ptr;
1317 1319
1318 // We assume these blocks are very rare so we do not optimize it.1320 // We assume these blocks are very rare so we do not optimize it.
@@ -1670,7 +1672,7 @@ decode_intra_mb: · 351 unmodified lines
1670 qmul = h->dequant4_coeff[0][s->qscale];1672 qmul = h->dequant4_coeff[0][s->qscale];
1671 for( i = 0; i < 16; i++ ) {1673 for( i = 0; i < 16; i++ ) {
1672 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i );1674 //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);
1674 }1676 }
1675 } else {1677 } else {
1676 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);1678 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
@@ -1680,7 +1682,7 @@ decode_intra_mb: · 3 unmodified lines
1680 for( i8x8 = 0; i8x8 < 4; i8x8++ ) {1682 for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
1681 if( cbp & (1<<i8x8) ) {1683 if( cbp & (1<<i8x8) ) {
1682 if( IS_8x8DCT(mb_type) ) {1684 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,
1684 scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64);1686 scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64);
1685 } else {1687 } else {
1686 qmul = h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale];1688 qmul = h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale];
@@ -1688,7 +1690,7 @@ decode_intra_mb: · 1 unmodified line
1688 const int index = 4*i8x8 + i4x4;1690 const int index = 4*i8x8 + i4x4;
1689 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );1691 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );
1690//START_TIMER1692//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);
1692//STOP_TIMER("decode_residual")1694//STOP_TIMER("decode_residual")
1693 }1695 }
1694 }1696 }
@@ -1703,7 +1705,7 @@ decode_intra_mb: · 8 unmodified lines
1703 int c;1705 int c;
1704 for( c = 0; c < 2; c++ ) {1706 for( c = 0; c < 2; c++ ) {
1705 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );1707 //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);
1707 }1709 }
1708 }1710 }
1709 1711
@@ -1714,7 +1716,7 @@ decode_intra_mb: · 4 unmodified lines
1714 for( i = 0; i < 4; i++ ) {1716 for( i = 0; i < 4; i++ ) {
1715 const int index = 16 + 4 * c + i;1717 const int index = 16 + 4 * c + i;
1716 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 );1718 //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);
1718 }1720 }
1719 }1721 }
1720 } else {1722 } else {
libavcodec/h264_cavlc.c+6−5
@@ -542,6 +542,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h){ · 541 unmodified lines
542 int partition_count;542 int partition_count;
543 unsigned int mb_type, cbp;543 unsigned int mb_type, cbp;
544 int dct8x8_allowed= h->pps.transform_8x8_mode;544 int dct8x8_allowed= h->pps.transform_8x8_mode;
545 const int pixel_shift = h->pixel_shift;
545 546
546 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;547 mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
547 548
@@ -961,7 +962,7 @@ decode_intra_mb: · 413 unmodified lines
961 for(i8x8=0; i8x8<4; i8x8++){962 for(i8x8=0; i8x8<4; i8x8++){
962 for(i4x4=0; i4x4<4; i4x4++){963 for(i4x4=0; i4x4<4; i4x4++){
963 const int index= i4x4 + 4*i8x8;964 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 ){
965 return -1;966 return -1;
966 }967 }
967 }968 }
@@ -973,7 +974,7 @@ decode_intra_mb: · 5 unmodified lines
973 for(i8x8=0; i8x8<4; i8x8++){974 for(i8x8=0; i8x8<4; i8x8++){
974 if(cbp & (1<<i8x8)){975 if(cbp & (1<<i8x8)){
975 if(IS_8x8DCT(mb_type)){976 if(IS_8x8DCT(mb_type)){
976 DCTELEM *buf = &h->mb[64*i8x8<<h->pixel_shift];977 DCTELEM *buf = &h->mb[64*i8x8 << pixel_shift];
977 uint8_t *nnz;978 uint8_t *nnz;
978 for(i4x4=0; i4x4<4; i4x4++){979 for(i4x4=0; i4x4<4; i4x4++){
979 if( decode_residual(h, gb, buf, i4x4+4*i8x8, scan8x8+16*i4x4,980 if( decode_residual(h, gb, buf, i4x4+4*i8x8, scan8x8+16*i4x4,
@@ -986,7 +987,7 @@ decode_intra_mb: · 6 unmodified lines
986 for(i4x4=0; i4x4<4; i4x4++){987 for(i4x4=0; i4x4<4; i4x4++){
987 const int index= i4x4 + 4*i8x8;988 const int index= i4x4 + 4*i8x8;
988 989
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 ){
990 return -1;991 return -1;
991 }992 }
992 }993 }
@@ -1000,7 +1001,7 @@ decode_intra_mb: · 7 unmodified lines
1000 1001
1001 if(cbp&0x30){1002 if(cbp&0x30){
1002 for(chroma_idx=0; chroma_idx<2; chroma_idx++)1003 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){
1004 return -1;1005 return -1;
1005 }1006 }
1006 }1007 }
@@ -1010,7 +1011,7 @@ decode_intra_mb: · 3 unmodified lines
1010 const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]];1011 const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]];
1011 for(i4x4=0; i4x4<4; i4x4++){1012 for(i4x4=0; i4x4<4; i4x4++){
1012 const int index= 16 + 4*chroma_idx + i4x4;1013 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){
1014 return -1;1015 return -1;
1015 }1016 }
1016 }1017 }
libavcodec/h264_loopfilter.c+59−165
@@ -101,197 +101,92 @@ static const uint8_t tc0_table[52*3][4] = { · 100 unmodified lines
101};101};
102 102
103static void av_always_inline filter_mb_edgev( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h) {103static 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;104 const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
105 const int qp_bd_offset = 6*(bit_depth-8);
106 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;105 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);106 const int alpha = alpha_table[index_a];
108 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);107 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
109 if (alpha ==0 || beta == 0) return;108 if (alpha ==0 || beta == 0) return;
110 109
111 if( bS[0] < 4 ) {110 if( bS[0] < 4 ) {
112 int8_t tc[4];111 int8_t tc[4];
113 tc[0] = tc0_table[index_a][bS[0]] << (bit_depth-8);112 tc[0] = tc0_table[index_a][bS[0]];
114 tc[1] = tc0_table[index_a][bS[1]] << (bit_depth-8);113 tc[1] = tc0_table[index_a][bS[1]];
115 tc[2] = tc0_table[index_a][bS[2]] << (bit_depth-8);114 tc[2] = tc0_table[index_a][bS[2]];
116 tc[3] = tc0_table[index_a][bS[3]] << (bit_depth-8);115 tc[3] = tc0_table[index_a][bS[3]];
117 h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc);116 h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc);
118 } else {117 } else {
119 h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);118 h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);
120 }119 }
121}120}
122static void av_always_inline filter_mb_edgecv( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {121static 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;122 const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
124 const int qp_bd_offset = 6*(bit_depth-8);
125 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;123 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);124 const int alpha = alpha_table[index_a];
127 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);125 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
128 if (alpha ==0 || beta == 0) return;126 if (alpha ==0 || beta == 0) return;
129 127
130 if( bS[0] < 4 ) {128 if( bS[0] < 4 ) {
131 int8_t tc[4];129 int8_t tc[4];
132 tc[0] = (tc0_table[index_a][bS[0]] << (bit_depth-8))+1;130 tc[0] = tc0_table[index_a][bS[0]]+1;
133 tc[1] = (tc0_table[index_a][bS[1]] << (bit_depth-8))+1;131 tc[1] = tc0_table[index_a][bS[1]]+1;
134 tc[2] = (tc0_table[index_a][bS[2]] << (bit_depth-8))+1;132 tc[2] = tc0_table[index_a][bS[2]]+1;
135 tc[3] = (tc0_table[index_a][bS[3]] << (bit_depth-8))+1;133 tc[3] = tc0_table[index_a][bS[3]]+1;
136 h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);134 h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
137 } else {135 } else {
138 h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);136 h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
139 }137 }
140}138}
141 139
142static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) {140static void filter_mb_mbaff_edgev( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) {
143 int i;141 const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
144 const int bit_depth = h->sps.bit_depth_luma;
145 const int qp_bd_offset = 6*(bit_depth-8);
146 int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;142 int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
147 int alpha = alpha_table[index_a] << (bit_depth-8);143 int alpha = alpha_table[index_a];
148 int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);144 int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
149 for( i = 0; i < 8; i++, pix += stride) {145 if (alpha ==0 || beta == 0) return;
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 ) {
199 146
200 if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){147 if( bS[0] < 4 ) {
201 if( FFABS( p2 - p0 ) < beta)148 int8_t tc[4];
202 {149 tc[0] = tc0_table[index_a][bS[0*bsi]];
203 const int p3 = pix[-4];150 tc[1] = tc0_table[index_a][bS[1*bsi]];
204 /* p0', p1', p2' */151 tc[2] = tc0_table[index_a][bS[2*bsi]];
205 pix[-1] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;152 tc[3] = tc0_table[index_a][bS[3*bsi]];
206 pix[-2] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;153 h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
207 pix[-3] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;154 } else {
208 } else {155 h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
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 }
231 }156 }
232}157}
233static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[4], int bsi, int qp ) {158static void filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, int16_t bS[7], int bsi, int qp ) {
234 int i;159 const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
235 const int bit_depth = h->sps.bit_depth_luma;
236 const int qp_bd_offset = 6*(bit_depth-8);
237 int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;160 int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;
238 int alpha = alpha_table[index_a] << (bit_depth-8);161 int alpha = alpha_table[index_a];
239 int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);162 int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
240 for( i = 0; i < 4; i++, pix += stride) {163 if (alpha ==0 || beta == 0) return;
241 const int bS_index = i*bsi;
242
243 if( bS[bS_index] == 0 ) {
244 continue;
245 }
246 164
247 if( bS[bS_index] < 4 ) {165 if( bS[0] < 4 ) {
248 const int tc = (tc0_table[index_a][bS[bS_index]] << (bit_depth-8)) + 1;166 int8_t tc[4];
249 const int p0 = pix[-1];167 tc[0] = tc0_table[index_a][bS[0*bsi]] + 1;
250 const int p1 = pix[-2];168 tc[1] = tc0_table[index_a][bS[1*bsi]] + 1;
251 const int q0 = pix[0];169 tc[2] = tc0_table[index_a][bS[2*bsi]] + 1;
252 const int q1 = pix[1];170 tc[3] = tc0_table[index_a][bS[3*bsi]] + 1;
253 171 h->h264dsp.h264_h_loop_filter_chroma_mbaff(pix, stride, alpha, beta, tc);
254 if( FFABS( p0 - q0 ) < alpha &&172 } else {
255 FFABS( p1 - p0 ) < beta &&173 h->h264dsp.h264_h_loop_filter_chroma_mbaff_intra(pix, stride, alpha, 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 }
278 }174 }
279}175}
280 176
281static void av_always_inline filter_mb_edgeh( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {177static 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;178 const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
283 const int qp_bd_offset = 6*(bit_depth-8);
284 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;179 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);180 const int alpha = alpha_table[index_a];
286 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);181 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
287 if (alpha ==0 || beta == 0) return;182 if (alpha ==0 || beta == 0) return;
288 183
289 if( bS[0] < 4 ) {184 if( bS[0] < 4 ) {
290 int8_t tc[4];185 int8_t tc[4];
291 tc[0] = tc0_table[index_a][bS[0]] << (bit_depth-8);186 tc[0] = tc0_table[index_a][bS[0]];
292 tc[1] = tc0_table[index_a][bS[1]] << (bit_depth-8);187 tc[1] = tc0_table[index_a][bS[1]];
293 tc[2] = tc0_table[index_a][bS[2]] << (bit_depth-8);188 tc[2] = tc0_table[index_a][bS[2]];
294 tc[3] = tc0_table[index_a][bS[3]] << (bit_depth-8);189 tc[3] = tc0_table[index_a][bS[3]];
295 h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);190 h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
296 } else {191 } else {
297 h->h264dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);192 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
299}194}
300 195
301static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h ) {196static 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;197 const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
303 const int qp_bd_offset = 6*(bit_depth-8);
304 const unsigned int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset;198 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);199 const int alpha = alpha_table[index_a];
306 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset] << (bit_depth-8);200 const int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset];
307 if (alpha ==0 || beta == 0) return;201 if (alpha ==0 || beta == 0) return;
308 202
309 if( bS[0] < 4 ) {203 if( bS[0] < 4 ) {
310 int8_t tc[4];204 int8_t tc[4];
311 tc[0] = (tc0_table[index_a][bS[0]] << (bit_depth-8))+1;205 tc[0] = tc0_table[index_a][bS[0]]+1;
312 tc[1] = (tc0_table[index_a][bS[1]] << (bit_depth-8))+1;206 tc[1] = tc0_table[index_a][bS[1]]+1;
313 tc[2] = (tc0_table[index_a][bS[2]] << (bit_depth-8))+1;207 tc[2] = tc0_table[index_a][bS[2]]+1;
314 tc[3] = (tc0_table[index_a][bS[3]] << (bit_depth-8))+1;208 tc[3] = tc0_table[index_a][bS[3]]+1;
315 h->h264dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);209 h->h264dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
316 } else {210 } else {
317 h->h264dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);211 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
650 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);544 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);
651 //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }545 //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
652 if( dir == 0 ) {546 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 );
654 if( (edge&1) == 0 ) {548 if( (edge&1) == 0 ) {
655 filter_mb_edgecv( &img_cb[2*edge<<h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], h);549 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);550 filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], h);
657 }551 }
658 } else {552 } else {
659 filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, h );553 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
70 QP(37,d), QP(37,d), QP(37,d), QP(38,d), QP(38,d), QP(38,d),\70 QP(37,d), QP(37,d), QP(37,d), QP(38,d), QP(38,d), QP(38,d),\
71 QP(39,d), QP(39,d), QP(39,d), QP(39,d)71 QP(39,d), QP(39,d), QP(39,d), QP(39,d)
72 72
73const uint8_t ff_h264_chroma_qp[3][QP_MAX_MAX+1] = {73const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM+1] = {
74 {74 {
75 CHROMA_QP_TABLE_END(8)75 CHROMA_QP_TABLE_END(8)
76 },76 },
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
629 * short_ref and long_ref buffers.629 * short_ref and long_ref buffers.
630 */630 */
631 av_log(h->s.avctx, AV_LOG_ERROR,631 av_log(h->s.avctx, AV_LOG_ERROR,
632 "number of reference frames exceeds max (probably "632 "number of reference frames (%d+%d) exceeds max (%d; 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);633 "corrupt input), discarding one\n",
634 h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
634 635
635 if (h->long_ref_count && !h->short_ref_count) {636 if (h->long_ref_count && !h->short_ref_count) {
636 for (i = 0; i < 16; ++i)637 for (i = 0; i < 16; ++i)
libavcodec/h264dsp.c+54−50
@@ -30,15 +30,15 @@ · 29 unmodified lines
30#include "h264dsp.h"30#include "h264dsp.h"
31 31
32#define BIT_DEPTH 832#define BIT_DEPTH 8
33#include "h264dsp_internal.h"33#include "h264dsp_template.c"
34#undef BIT_DEPTH34#undef BIT_DEPTH
35 35
36#define BIT_DEPTH 936#define BIT_DEPTH 9
37#include "h264dsp_internal.h"37#include "h264dsp_template.c"
38#undef BIT_DEPTH38#undef BIT_DEPTH
39 39
40#define BIT_DEPTH 1040#define BIT_DEPTH 10
41#include "h264dsp_internal.h"41#include "h264dsp_template.c"
42#undef BIT_DEPTH42#undef BIT_DEPTH
43 43
44void ff_h264dsp_init(H264DSPContext *c, const int bit_depth)44void 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
47#define FUNC(a, depth) a ## _ ## depth ## _c47#define FUNC(a, depth) a ## _ ## depth ## _c
48 48
49#define H264_DSP(depth) \49#define H264_DSP(depth) \
50 c->h264_idct_add = FUNC(ff_h264_idct_add , depth);\50 c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
51 c->h264_idct8_add = FUNC(ff_h264_idct8_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);\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);\53 c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
54 c->h264_idct_add16 = FUNC(ff_h264_idct_add16 , depth);\54 c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
55 c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4 , depth);\55 c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\
56 c->h264_idct_add8 = FUNC(ff_h264_idct_add8 , depth);\56 c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\
57 c->h264_idct_add16intra = FUNC(ff_h264_idct_add16intra , 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);\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);\59 c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\
60\60\
61 c->weight_h264_pixels_tab[0] = FUNC( weight_h264_pixels16x16 , 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);\62 c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels16x8, depth);\
63 c->weight_h264_pixels_tab[2] = FUNC( weight_h264_pixels8x16 , 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);\64 c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels8x8, depth);\
65 c->weight_h264_pixels_tab[4] = FUNC( weight_h264_pixels8x4 , 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);\66 c->weight_h264_pixels_tab[5]= FUNC(weight_h264_pixels4x8, depth);\
67 c->weight_h264_pixels_tab[6] = FUNC( weight_h264_pixels4x4 , 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);\68 c->weight_h264_pixels_tab[7]= FUNC(weight_h264_pixels4x2, depth);\
69 c->weight_h264_pixels_tab[8] = FUNC( weight_h264_pixels2x4 , 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);\70 c->weight_h264_pixels_tab[9]= FUNC(weight_h264_pixels2x2, depth);\
71 c->biweight_h264_pixels_tab[0] = FUNC(biweight_h264_pixels16x16 , 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);\72 c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels16x8, depth);\
73 c->biweight_h264_pixels_tab[2] = FUNC(biweight_h264_pixels8x16 , 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);\74 c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels8x8, depth);\
75 c->biweight_h264_pixels_tab[4] = FUNC(biweight_h264_pixels8x4 , 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);\76 c->biweight_h264_pixels_tab[5]= FUNC(biweight_h264_pixels4x8, depth);\
77 c->biweight_h264_pixels_tab[6] = FUNC(biweight_h264_pixels4x4 , 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);\78 c->biweight_h264_pixels_tab[7]= FUNC(biweight_h264_pixels4x2, depth);\
79 c->biweight_h264_pixels_tab[8] = FUNC(biweight_h264_pixels2x4 , 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);\80 c->biweight_h264_pixels_tab[9]= FUNC(biweight_h264_pixels2x2, depth);\
81\81\
82 c->h264_v_loop_filter_luma = FUNC(h264_v_loop_filter_luma , 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);\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);\84 c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
85 c->h264_h_loop_filter_luma_intra = FUNC(h264_h_loop_filter_luma_intra , depth);\85 c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, depth);\
86 c->h264_v_loop_filter_chroma = FUNC(h264_v_loop_filter_chroma , depth);\86 c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
87 c->h264_h_loop_filter_chroma = FUNC(h264_h_loop_filter_chroma , 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_intra = FUNC(h264_v_loop_filter_chroma_intra, depth);\88 c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
89 c->h264_h_loop_filter_chroma_intra = FUNC(h264_h_loop_filter_chroma_intra, 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);\
90 c->h264_loop_filter_strength= NULL;94 c->h264_loop_filter_strength= NULL;
91 95
92 switch (bit_depth) {96 switch (bit_depth) {
93 case 9:97 case 9:
94 H264_DSP(9);98 H264_DSP(9);
95 break;99 break;
96 case 10:100 case 10:
97 H264_DSP(10);101 H264_DSP(10);
98 break;102 break;
99 default:103 default:
100 H264_DSP(8);104 H264_DSP(8);
101 break;105 break;
102 }106 }
103 107
104 if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth);108 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
45 /* loop filter */45 /* loop filter */
46 void (*h264_v_loop_filter_luma)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0);46 void (*h264_v_loop_filter_luma)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0);
47 void (*h264_h_loop_filter_luma)(uint8_t *pix/*align 4 */, int stride, int alpha, int beta, int8_t *tc0);47 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);
48 /* v/h_loop_filter_luma_intra: align 16 */49 /* v/h_loop_filter_luma_intra: align 16 */
49 void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta);50 void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta);
50 void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta);51 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);
51 void (*h264_v_loop_filter_chroma)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0);53 void (*h264_v_loop_filter_chroma)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta, int8_t *tc0);
52 void (*h264_h_loop_filter_chroma)(uint8_t *pix/*align 4*/, int stride, int alpha, int beta, int8_t *tc0);54 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);
53 void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);56 void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);
54 void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix/*align 8*/, int stride, int alpha, int beta);57 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);
55 // h264_loop_filter_strength: simd only. the C version is inlined in h264.c59 // h264_loop_filter_strength: simd only. the C version is inlined in h264.c
56 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],60 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],
57 int bidir, int edges, int step, int mask_mv0, int mask_mv1, int field);61 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) \
33static 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} \
61static 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
90H264_WEIGHT(16,16)
91H264_WEIGHT(16,8)
92H264_WEIGHT(8,16)
93H264_WEIGHT(8,8)
94H264_WEIGHT(8,4)
95H264_WEIGHT(4,8)
96H264_WEIGHT(4,4)
97H264_WEIGHT(4,2)
98H264_WEIGHT(2,4)
99H264_WEIGHT(2,2)
100
101#undef op_scale1
102#undef op_scale2
103#undef H264_WEIGHT
104
105static 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}
153static 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}
157static 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}
161static 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
166static 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}
219static 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}
223static 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}
227static 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
232static 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}
265static 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}
269static 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}
273static 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
278static 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}
302static 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}
306static 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}
310static 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
26 */26 */
27 27
28#define BIT_DEPTH 828#define BIT_DEPTH 8
29#include "h264idct_internal.h"29#include "h264idct_template.c"
30#undef BIT_DEPTH30#undef BIT_DEPTH
31 31
32#define BIT_DEPTH 932#define BIT_DEPTH 9
33#include "h264idct_internal.h"33#include "h264idct_template.c"
34#undef BIT_DEPTH34#undef BIT_DEPTH
35 35
36#define BIT_DEPTH 1036#define BIT_DEPTH 10
37#include "h264idct_internal.h"37#include "h264idct_template.c"
38#undef BIT_DEPTH38#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
33static 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
45static 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
79void FUNCC(ff_h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride){
80 FUNCC(idct_internal)(dst, block, stride, 4, 6, 1);
81}
82
83void 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
87void 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
91void 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
165void 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
179void 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
193void 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
204void 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
212void 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
223void 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 */
236void 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
271void 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
28#include "h264pred.h"28#include "h264pred.h"
29 29
30#define BIT_DEPTH 830#define BIT_DEPTH 8
31#include "h264pred_internal.h"31#include "h264pred_template.c"
32#undef BIT_DEPTH32#undef BIT_DEPTH
33 33
34#define BIT_DEPTH 934#define BIT_DEPTH 9
35#include "h264pred_internal.h"35#include "h264pred_template.c"
36#undef BIT_DEPTH36#undef BIT_DEPTH
37 37
38#define BIT_DEPTH 1038#define BIT_DEPTH 10
39#include "h264pred_internal.h"39#include "h264pred_template.c"
40#undef BIT_DEPTH40#undef BIT_DEPTH
41 41
42static 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
57static 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
67static 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
91static 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
115static 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
138static 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
161static 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
168static 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
174static 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
196static 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
220static 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
243static 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
258static void pred16x16_plane_svq3_c(uint8_t *src, int stride){
259 pred16x16_plane_compat_8_c(src, stride, 1, 0);
260}
261
262static void pred16x16_plane_rv40_c(uint8_t *src, int stride){
263 pred16x16_plane_compat_8_c(src, stride, 0, 1);
264}
265
266static 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
293static 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
308static 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
323static 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
344static 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
42/**363/**
43 * Set the intra prediction function pointers.364 * Set the intra prediction function pointers.
44 */365 */
@@ -49,26 +370,27 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 4 unmodified lines
49#undef FUNCC370#undef FUNCC
50#define FUNC(a, depth) a ## _ ## depth371#define FUNC(a, depth) a ## _ ## depth
51#define FUNCC(a, depth) a ## _ ## depth ## _c372#define FUNCC(a, depth) a ## _ ## depth ## _c
373#define FUNCD(a) a ## _c
52 374
53#define H264_PRED(depth) \375#define H264_PRED(depth) \
54 if(codec_id != CODEC_ID_RV40){\376 if(codec_id != CODEC_ID_RV40){\
55 if(codec_id == CODEC_ID_VP8) {\377 if(codec_id == CODEC_ID_VP8) {\
56 h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical_vp8 , depth);\378 h->pred4x4[VERT_PRED ]= FUNCD(pred4x4_vertical_vp8);\
57 h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal_vp8 , depth);\379 h->pred4x4[HOR_PRED ]= FUNCD(pred4x4_horizontal_vp8);\
58 } else {\380 } else {\
59 h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\381 h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
60 h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\382 h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
61 }\383 }\
62 h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\384 h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\
63 if(codec_id == CODEC_ID_SVQ3)\385 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);\
65 else\387 else\
66 h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left , depth);\388 h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left , depth);\
67 h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\389 h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\
68 h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\390 h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\
69 h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\391 h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\
70 if (codec_id == CODEC_ID_VP8) {\392 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);\
72 } else\394 } else\
73 h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left , depth);\395 h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left , depth);\
74 h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up , depth);\396 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
77 h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\399 h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\
78 h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\400 h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\
79 } else {\401 } else {\
80 h->pred4x4[TM_VP8_PRED ]= FUNCC(pred4x4_tm_vp8 , depth);\402 h->pred4x4[TM_VP8_PRED ]= FUNCD(pred4x4_tm_vp8);\
81 h->pred4x4[DC_127_PRED ]= FUNCC(pred4x4_127_dc , depth);\403 h->pred4x4[DC_127_PRED ]= FUNCC(pred4x4_127_dc , depth);\
82 h->pred4x4[DC_129_PRED ]= FUNCC(pred4x4_129_dc , depth);\404 h->pred4x4[DC_129_PRED ]= FUNCC(pred4x4_129_dc , depth);\
83 h->pred4x4[VERT_VP8_PRED ]= FUNCC(pred4x4_vertical , depth);\405 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
87 h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\409 h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
88 h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\410 h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
89 h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\411 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);\
91 h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\413 h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\
92 h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\414 h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\
93 h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\415 h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\
94 h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left_rv40, depth);\416 h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_rv40);\
95 h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up_rv40, depth);\417 h->pred4x4[HOR_UP_PRED ]= FUNCD(pred4x4_horizontal_up_rv40);\
96 h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\418 h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\
97 h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\419 h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\
98 h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\420 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);\421 h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_down_left_rv40_nodown);\
100 h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCC(pred4x4_horizontal_up_rv40_nodown , depth);\422 h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCD(pred4x4_horizontal_up_rv40_nodown);\
101 h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCC(pred4x4_vertical_left_rv40_nodown , depth);\423 h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_vertical_left_rv40_nodown);\
102 }\424 }\
103\425\
104 h->pred8x8l[VERT_PRED ]= FUNCC(pred8x8l_vertical , depth);\426 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
119 if (codec_id != CODEC_ID_VP8) {\441 if (codec_id != CODEC_ID_VP8) {\
120 h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\442 h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\
121 } else\443 } else\
122 h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_tm_vp8 , depth);\444 h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
123 if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\445 if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\
124 h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\446 h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
125 h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\447 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
129 h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\451 h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
130 h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\452 h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
131 }else{\453 }else{\
132 h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc_rv40 , depth);\454 h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\
133 h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc_rv40 , depth);\455 h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\
134 h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc_rv40 , depth);\456 h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\
135 if (codec_id == CODEC_ID_VP8) {\457 if (codec_id == CODEC_ID_VP8) {\
136 h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc , depth);\458 h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc , depth);\
137 h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\459 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
144 h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\466 h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\
145 switch(codec_id){\467 switch(codec_id){\
146 case CODEC_ID_SVQ3:\468 case CODEC_ID_SVQ3:\
147 h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane_svq3 , depth);\469 h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_svq3);\
148 break;\470 break;\
149 case CODEC_ID_RV40:\471 case CODEC_ID_RV40:\
150 h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane_rv40 , depth);\472 h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_rv40);\
151 break;\473 break;\
152 case CODEC_ID_VP8:\474 case CODEC_ID_VP8:\
153 h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_tm_vp8 , depth);\475 h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_tm_vp8);\
154 h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\476 h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\
155 h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc , depth);\477 h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc , depth);\
156 break;\478 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
31static 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
41static 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
50static 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
62static 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
73static 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
84static 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
93static 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
102static 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
136static 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
161static 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
187static 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
212static 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
237static 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
260static 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
285static 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
302static 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
324static 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
342static 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
356static 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) \
371static 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
378PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1);
379PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0);
380PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1);
381
382static 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
427static void FUNCC(pred16x16_plane)(uint8_t *src, int stride){
428 FUNCC(pred16x16_plane_compat)(src, stride, 0, 0);
429}
430
431static 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
444static 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)\
456static 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
466PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1);
467PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0);
468PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1);
469
470static 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
495static 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
520static 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!
549static 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
554static 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
559static 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
565static 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
571static 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
644static 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}
651static 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}
660static 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}
669static 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}
680static 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}
691static 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}
711static 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}
733static 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}
756static 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}
786static 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}
816static 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}
845static 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
879static 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
896static 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
912static 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
933static 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
953static 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
959static 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
965static 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
971static 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
34CLIP_PIXEL( 9)
35CLIP_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
158 const int32_t *samples, int blocksize, int min_order,158 const int32_t *samples, int blocksize, int min_order,
159 int max_order, int precision,159 int max_order, int precision,
160 int32_t coefs[][MAX_LPC_ORDER], int *shift,160 int32_t coefs[][MAX_LPC_ORDER], int *shift,
161 enum AVLPCType lpc_type, int lpc_passes,161 enum FFLPCType lpc_type, int lpc_passes,
162 int omethod, int max_shift, int zero_shift)162 int omethod, int max_shift, int zero_shift)
163{163{
164 double autoc[MAX_LPC_ORDER+1];164 double autoc[MAX_LPC_ORDER+1];
@@ -168,7 +168,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 3 unmodified lines
168 int opt_order;168 int opt_order;
169 169
170 assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&170 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);
172 172
173 /* reinit LPC context if parameters have changed */173 /* reinit LPC context if parameters have changed */
174 if (blocksize != s->blocksize || max_order != s->max_order ||174 if (blocksize != s->blocksize || max_order != s->max_order ||
@@ -177,7 +177,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 2 unmodified lines
177 ff_lpc_init(s, blocksize, max_order, lpc_type);177 ff_lpc_init(s, blocksize, max_order, lpc_type);
178 }178 }
179 179
180 if (lpc_type == AV_LPC_TYPE_LEVINSON) {180 if (lpc_type == FF_LPC_TYPE_LEVINSON) {
181 double *windowed_samples = s->windowed_samples + max_order;181 double *windowed_samples = s->windowed_samples + max_order;
182 182
183 s->lpc_apply_welch_window(samples, blocksize, windowed_samples);183 s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
@@ -188,7 +188,7 @@ int ff_lpc_calc_coefs(LPCContext *s, · 4 unmodified lines
188 188
189 for(i=0; i<max_order; i++)189 for(i=0; i<max_order; i++)
190 ref[i] = fabs(lpc[i][i]);190 ref[i] = fabs(lpc[i][i]);
191 } else if (lpc_type == AV_LPC_TYPE_CHOLESKY) {191 } else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
192 LLSModel m[2];192 LLSModel m[2];
193 double var[MAX_LPC_ORDER+1], av_uninit(weight);193 double var[MAX_LPC_ORDER+1], av_uninit(weight);
194 194
@@ -241,13 +241,13 @@ int ff_lpc_calc_coefs(LPCContext *s, · 46 unmodified lines
241}241}
242 242
243av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,243av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
244 enum AVLPCType lpc_type)244 enum FFLPCType lpc_type)
245{245{
246 s->blocksize = blocksize;246 s->blocksize = blocksize;
247 s->max_order = max_order;247 s->max_order = max_order;
248 s->lpc_type = lpc_type;248 s->lpc_type = lpc_type;
249 249
250 if (lpc_type == AV_LPC_TYPE_LEVINSON) {250 if (lpc_type == FF_LPC_TYPE_LEVINSON) {
251 s->windowed_samples = av_mallocz((blocksize + max_order + 2) *251 s->windowed_samples = av_mallocz((blocksize + max_order + 2) *
252 sizeof(*s->windowed_samples));252 sizeof(*s->windowed_samples));
253 if (!s->windowed_samples)253 if (!s->windowed_samples)
libavcodec/lpc.h+14−3
@@ -35,11 +35,22 @@ · 34 unmodified lines
35#define MIN_LPC_ORDER 135#define MIN_LPC_ORDER 1
36#define MAX_LPC_ORDER 3236#define MAX_LPC_ORDER 32
37 37
38/**
39 * LPC analysis type
40 */
41enum 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};
38 49
39typedef struct LPCContext {50typedef struct LPCContext {
40 int blocksize;51 int blocksize;
41 int max_order;52 int max_order;
42 enum AVLPCType lpc_type;53 enum FFLPCType lpc_type;
43 double *windowed_samples;54 double *windowed_samples;
44 55
45 /**56 /**
@@ -77,14 +88,14 @@ int ff_lpc_calc_coefs(LPCContext *s, · 31 unmodified lines
77 const int32_t *samples, int blocksize, int min_order,88 const int32_t *samples, int blocksize, int min_order,
78 int max_order, int precision,89 int max_order, int precision,
79 int32_t coefs[][MAX_LPC_ORDER], int *shift,90 int32_t coefs[][MAX_LPC_ORDER], int *shift,
80 enum AVLPCType lpc_type, int lpc_passes,91 enum FFLPCType lpc_type, int lpc_passes,
81 int omethod, int max_shift, int zero_shift);92 int omethod, int max_shift, int zero_shift);
82 93
83/**94/**
84 * Initialize LPCContext.95 * Initialize LPCContext.
85 */96 */
86int ff_lpc_init(LPCContext *s, int blocksize, int max_order,97int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
87 enum AVLPCType lpc_type);98 enum FFLPCType lpc_type);
88void ff_lpc_init_x86(LPCContext *s);99void ff_lpc_init_x86(LPCContext *s);
89 100
90/**101/**
libavcodec/mlib/dsputil_mlib.c+2−2
@@ -421,13 +421,13 @@ static void ff_fdct_mlib(DCTELEM *data) · 420 unmodified lines
421 421
422void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)422void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)
423{423{
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;
425 425
426 c->get_pixels = get_pixels_mlib;426 c->get_pixels = get_pixels_mlib;
427 c->diff_pixels = diff_pixels_mlib;427 c->diff_pixels = diff_pixels_mlib;
428 c->add_pixels_clamped = add_pixels_clamped_mlib;428 c->add_pixels_clamped = add_pixels_clamped_mlib;
429 429
430 if (!h264_high_depth) {430 if (!high_bit_depth) {
431 c->put_pixels_tab[0][0] = put_pixels16_mlib;431 c->put_pixels_tab[0][0] = put_pixels16_mlib;
432 c->put_pixels_tab[0][1] = put_pixels16_x2_mlib;432 c->put_pixels_tab[0][1] = put_pixels16_x2_mlib;
433 c->put_pixels_tab[0][2] = put_pixels16_y2_mlib;433 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
103{"umh", "umh motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" },103{"umh", "umh motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" },
104{"iter", "iter motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" },104{"iter", "iter motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" },
105{"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},105{"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},
107{"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, {.dbl = 12 }, INT_MIN, INT_MAX, V|E},107{"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, {.dbl = 12 }, INT_MIN, INT_MAX, V|E},
108{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},108{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
109{"ac", "set number of audio channels", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},109{"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
224{"left", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"},224{"left", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"},
225{"plane", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"},225{"plane", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"},
226{"median", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"},226{"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},
228{"debug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"},228{"debug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"},
229{"pict", "picture info", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},229{"pict", "picture info", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},
230{"rc", "rate control", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_RC }, INT_MIN, INT_MAX, V|E, "debug"},230{"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
380{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_VLC }, INT_MIN, INT_MAX, V|E, "flags2"},380{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_VLC }, INT_MIN, INT_MAX, V|E, "flags2"},
381{"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, {.dbl = 40 }, 1, INT_MAX, V|E},381{"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, {.dbl = 40 }, 1, INT_MAX, V|E},
382{"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, {.dbl = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},382{"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},
384{"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},383{"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
385{"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},384{"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},385#if FF_API_FLAC_GLOBAL_OPTS
387{"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},386{"lpc_coeff_precision", "deprecated, use flac-specific options", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 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},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
389{"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},391{"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},
390{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"},392{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"},
391{"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"},393{"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
416{"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"},418{"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"},
417{"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},419{"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},
418{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX },420{"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},
420{"none", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_NONE }, INT_MIN, INT_MAX, A|E, "lpc_type"},423{"none", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_NONE }, INT_MIN, INT_MAX, A|E, "lpc_type"},
421{"fixed", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, A|E, "lpc_type"},424{"fixed", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, A|E, "lpc_type"},
422{"levinson", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, A|E, "lpc_type"},425{"levinson", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, A|E, "lpc_type"},
423{"cholesky", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, A|E, "lpc_type"},426{"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
425{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E},429{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E},
426{"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"},430{"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"},
427{"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"},431{"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
1384 1384
1385void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx)1385void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx)
1386{1386{
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;
1388 1388
1389 c->pix_abs[0][1] = sad16_x2_altivec;1389 c->pix_abs[0][1] = sad16_x2_altivec;
1390 c->pix_abs[0][2] = sad16_y2_altivec;1390 c->pix_abs[0][2] = sad16_y2_altivec;
@@ -1399,10 +1399,10 @@ void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
1399 c->pix_sum = pix_sum_altivec;1399 c->pix_sum = pix_sum_altivec;
1400 c->diff_pixels = diff_pixels_altivec;1400 c->diff_pixels = diff_pixels_altivec;
1401 c->get_pixels = get_pixels_altivec;1401 c->get_pixels = get_pixels_altivec;
1402 if (!h264_high_depth)1402 if (!high_bit_depth)
1403 c->clear_block = clear_block_altivec;1403 c->clear_block = clear_block_altivec;
1404 c->add_bytes= add_bytes_altivec;1404 c->add_bytes= add_bytes_altivec;
1405 if (!h264_high_depth) {1405 if (!high_bit_depth) {
1406 c->put_pixels_tab[0][0] = put_pixels16_altivec;1406 c->put_pixels_tab[0][0] = put_pixels16_altivec;
1407 /* the two functions do the same thing, so use the same code */1407 /* the two functions do the same thing, so use the same code */
1408 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_altivec;1408 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
153 153
154void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)154void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
155{155{
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;
157 157
158 // Common optimizations whether AltiVec is available or not158 // Common optimizations whether AltiVec is available or not
159 c->prefetch = prefetch_ppc;159 c->prefetch = prefetch_ppc;
160 if (!h264_high_depth) {160 if (!high_bit_depth) {
161 switch (check_dcbzl_effect()) {161 switch (check_dcbzl_effect()) {
162 case 32:162 case 32:
163 c->clear_blocks = clear_blocks_dcbz32_ppc;163 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
965H264_WEIGHT( 8, 4)965H264_WEIGHT( 8, 4)
966 966
967void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {967void 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;
969 969
970 if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {970 if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
971 if (!h264_high_depth) {971 if (!high_bit_depth) {
972 c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;972 c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
973 c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;973 c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
974 974
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
142void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)142void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
143{143{
144 const int idct_algo= avctx->idct_algo;144 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;
146 146
147 if (!h264_high_depth) {147 if (!high_bit_depth) {
148 c->clear_blocks = clear_blocks_mmi;148 c->clear_blocks = clear_blocks_mmi;
149 149
150 c->put_pixels_tab[1][0] = put_pixels8_mmi;150 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
54 ractx->lpc_coef[1] = ractx->lpc_tables[1];54 ractx->lpc_coef[1] = ractx->lpc_tables[1];
55 ractx->avctx = avctx;55 ractx->avctx = avctx;
56 ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,56 ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER,
57 AV_LPC_TYPE_LEVINSON);57 FF_LPC_TYPE_LEVINSON);
58 return ret;58 return ret;
59}59}
60 60
@@ -461,7 +461,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, · 400 unmodified lines
461 32)];461 32)];
462 462
463 ff_lpc_calc_coefs(&ractx->lpc_ctx, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER,463 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,
465 0, ORDER_METHOD_EST, 12, 0);465 0, ORDER_METHOD_EST, 12, 0);
466 for (i = 0; i < LPC_ORDER; i++)466 for (i = 0; i < LPC_ORDER; i++)
467 block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<467 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
333 333
334void dsputil_init_align(DSPContext* c, AVCodecContext *avctx)334void dsputil_init_align(DSPContext* c, AVCodecContext *avctx)
335{335{
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;
337 337
338 if (!h264_high_depth) {338 if (!high_bit_depth) {
339 c->put_pixels_tab[0][0] = put_rnd_pixels16_o;339 c->put_pixels_tab[0][0] = put_rnd_pixels16_o;
340 c->put_pixels_tab[0][1] = put_rnd_pixels16_x;340 c->put_pixels_tab[0][1] = put_rnd_pixels16_x;
341 c->put_pixels_tab[0][2] = put_rnd_pixels16_y;341 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
405 dspfunc(avg_qpel, 1, 8);405 dspfunc(avg_qpel, 1, 8);
406 /* dspfunc(avg_no_rnd_qpel, 1, 8); */406 /* dspfunc(avg_no_rnd_qpel, 1, 8); */
407 407
408 if (!h264_high_depth) {408 if (!high_bit_depth) {
409 dspfunc(put_h264_qpel, 0, 16);409 dspfunc(put_h264_qpel, 0, 16);
410 dspfunc(put_h264_qpel, 1, 8);410 dspfunc(put_h264_qpel, 1, 8);
411 dspfunc(put_h264_qpel, 2, 4);411 dspfunc(put_h264_qpel, 2, 4);
@@ -415,7 +415,7 @@ void dsputil_init_align(DSPContext* c, AVCodecContext *avctx) · 3 unmodified lines
415 }415 }
416 416
417#undef dspfunc417#undef dspfunc
418 if (!h264_high_depth) {418 if (!high_bit_depth) {
419 c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_sh4;419 c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_sh4;
420 c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_sh4;420 c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_sh4;
421 c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_sh4;421 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
92void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)92void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
93{93{
94 const int idct_algo= avctx->idct_algo;94 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;
96 dsputil_init_align(c,avctx);96 dsputil_init_align(c,avctx);
97 97
98 if (!h264_high_depth)98 if (!high_bit_depth)
99 c->clear_blocks = clear_blocks_sh4;99 c->clear_blocks = clear_blocks_sh4;
100 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){100 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){
101 c->idct_put = idct_put;101 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
3953{3953{
3954 /* VIS-specific optimizations */3954 /* VIS-specific optimizations */
3955 int accel = vis_level ();3955 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;
3957 3957
3958 if (accel & ACCEL_SPARC_VIS) {3958 if (accel & ACCEL_SPARC_VIS) {
3959 if(avctx->idct_algo==FF_IDCT_SIMPLEVIS){3959 if(avctx->idct_algo==FF_IDCT_SIMPLEVIS){
@@ -3963,7 +3963,7 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx) · 3 unmodified lines
3963 c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;3963 c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
3964 }3964 }
3965 3965
3966 if (!h264_high_depth) {3966 if (!high_bit_depth) {
3967 c->put_pixels_tab[0][0] = MC_put_o_16_vis;3967 c->put_pixels_tab[0][0] = MC_put_o_16_vis;
3968 c->put_pixels_tab[0][1] = MC_put_x_16_vis;3968 c->put_pixels_tab[0][1] = MC_put_x_16_vis;
3969 c->put_pixels_tab[0][2] = MC_put_y_16_vis;3969 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
1297unsigned int ff_toupper4(unsigned int x)1297unsigned int ff_toupper4(unsigned int x)
1298{1298{
1299 return toupper( x &0xFF)1299 return toupper( x &0xFF)
1300 + (toupper((x>>8 )&0xFF)<<8 )1300 + (toupper((x>>8 )&0xFF)<<8 )
1301 + (toupper((x>>16)&0xFF)<<16)1301 + (toupper((x>>16)&0xFF)<<16)
1302 + (toupper((x>>24)&0xFF)<<24);1302 + (toupper((x>>24)&0xFF)<<24);
1303}1303}
1304 1304
1305#if !HAVE_PTHREADS1305#if !HAVE_PTHREADS
libavcodec/version.h+3−0
@@ -62,5 +62,8 @@ · 61 unmodified lines
62#ifndef FF_API_OLD_FF_PICT_TYPES62#ifndef FF_API_OLD_FF_PICT_TYPES
63#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)63#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
64#endif64#endif
65#ifndef FF_API_FLAC_GLOBAL_OPTS
66#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
67#endif
65 68
66#endif /* AVCODEC_VERSION_H */69#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
2322void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)2322void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
2323{2323{
2324 int mm_flags = av_get_cpu_flags();2324 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;
2326 2326
2327 if (avctx->dsp_mask) {2327 if (avctx->dsp_mask) {
2328 if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)2328 if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
@@ -2404,7 +2404,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 75 unmodified lines
2404 c->put_pixels_clamped = ff_put_pixels_clamped_mmx;2404 c->put_pixels_clamped = ff_put_pixels_clamped_mmx;
2405 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;2405 c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx;
2406 c->add_pixels_clamped = ff_add_pixels_clamped_mmx;2406 c->add_pixels_clamped = ff_add_pixels_clamped_mmx;
2407 if (!h264_high_depth) {2407 if (!high_bit_depth) {
2408 c->clear_block = clear_block_mmx;2408 c->clear_block = clear_block_mmx;
2409 c->clear_blocks = clear_blocks_mmx;2409 c->clear_blocks = clear_blocks_mmx;
2410 if ((mm_flags & AV_CPU_FLAG_SSE) &&2410 if ((mm_flags & AV_CPU_FLAG_SSE) &&
@@ -2421,7 +2421,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 10 unmodified lines
2421 c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \2421 c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \
2422 c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU2422 c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU
2423 2423
2424 if (!h264_high_depth) {2424 if (!high_bit_depth) {
2425 SET_HPEL_FUNCS(put, 0, 16, mmx);2425 SET_HPEL_FUNCS(put, 0, 16, mmx);
2426 SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx);2426 SET_HPEL_FUNCS(put_no_rnd, 0, 16, mmx);
2427 SET_HPEL_FUNCS(avg, 0, 16, mmx);2427 SET_HPEL_FUNCS(avg, 0, 16, mmx);
@@ -2436,13 +2436,13 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
2436 c->gmc= gmc_mmx;2436 c->gmc= gmc_mmx;
2437#endif2437#endif
2438#if ARCH_X86_32 && HAVE_YASM2438#if ARCH_X86_32 && HAVE_YASM
2439 if (!h264_high_depth)2439 if (!high_bit_depth)
2440 c->emulated_edge_mc = emulated_edge_mc_mmx;2440 c->emulated_edge_mc = emulated_edge_mc_mmx;
2441#endif2441#endif
2442 2442
2443 c->add_bytes= add_bytes_mmx;2443 c->add_bytes= add_bytes_mmx;
2444 2444
2445 if (!h264_high_depth)2445 if (!high_bit_depth)
2446 c->draw_edges = draw_edges_mmx;2446 c->draw_edges = draw_edges_mmx;
2447 2447
2448 if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {2448 if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
@@ -2451,7 +2451,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 2 unmodified lines
2451 }2451 }
2452 2452
2453#if HAVE_YASM2453#if HAVE_YASM
2454 if (!h264_high_depth) {2454 if (!high_bit_depth) {
2455 c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_mmx_rnd;2455 c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_mmx_rnd;
2456 c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_mmx;2456 c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_mmx;
2457 }2457 }
@@ -2463,7 +2463,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 5 unmodified lines
2463 if (mm_flags & AV_CPU_FLAG_MMX2) {2463 if (mm_flags & AV_CPU_FLAG_MMX2) {
2464 c->prefetch = prefetch_mmx2;2464 c->prefetch = prefetch_mmx2;
2465 2465
2466 if (!h264_high_depth) {2466 if (!high_bit_depth) {
2467 c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;2467 c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
2468 c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;2468 c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
2469 2469
@@ -2480,7 +2480,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 10 unmodified lines
2480 }2480 }
2481 2481
2482 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){2482 if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
2483 if (!h264_high_depth) {2483 if (!high_bit_depth) {
2484 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;2484 c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
2485 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;2485 c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
2486 c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;2486 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
2529 SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2);2529 SET_QPEL_FUNCS(avg_qpel, 0, 16, mmx2);
2530 SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2);2530 SET_QPEL_FUNCS(avg_qpel, 1, 8, mmx2);
2531 2531
2532 if (!h264_high_depth) {2532 if (!high_bit_depth) {
2533 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2);2533 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmx2);
2534 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2);2534 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmx2);
2535 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2);2535 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmx2);
@@ -2547,7 +2547,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 11 unmodified lines
2547 c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_mmx2;2547 c->avg_rv40_chroma_pixels_tab[0]= ff_avg_rv40_chroma_mc8_mmx2;
2548 c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_mmx2;2548 c->avg_rv40_chroma_pixels_tab[1]= ff_avg_rv40_chroma_mc4_mmx2;
2549 2549
2550 if (!h264_high_depth) {2550 if (!high_bit_depth) {
2551 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_mmx2_rnd;2551 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_mmx2_rnd;
2552 c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_mmx2;2552 c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_mmx2;
2553 c->avg_h264_chroma_pixels_tab[2]= ff_avg_h264_chroma_mc2_mmx2;2553 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
2564 } else if (mm_flags & AV_CPU_FLAG_3DNOW) {2564 } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
2565 c->prefetch = prefetch_3dnow;2565 c->prefetch = prefetch_3dnow;
2566 2566
2567 if (!h264_high_depth) {2567 if (!high_bit_depth) {
2568 c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;2568 c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
2569 c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;2569 c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
2570 2570
@@ -2602,7 +2602,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 31 unmodified lines
2602 SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow);2602 SET_QPEL_FUNCS(avg_qpel, 0, 16, 3dnow);
2603 SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow);2603 SET_QPEL_FUNCS(avg_qpel, 1, 8, 3dnow);
2604 2604
2605 if (!h264_high_depth) {2605 if (!high_bit_depth) {
2606 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow);2606 SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 3dnow);
2607 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow);2607 SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 3dnow);
2608 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow);2608 SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 3dnow);
@@ -2617,7 +2617,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
2617 SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);2617 SET_QPEL_FUNCS(avg_2tap_qpel, 1, 8, 3dnow);
2618 2618
2619#if HAVE_YASM2619#if HAVE_YASM
2620 if (!h264_high_depth) {2620 if (!high_bit_depth) {
2621 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_3dnow_rnd;2621 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_3dnow_rnd;
2622 c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_3dnow;2622 c->avg_h264_chroma_pixels_tab[1]= ff_avg_h264_chroma_mc4_3dnow;
2623 }2623 }
@@ -2635,7 +2635,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 11 unmodified lines
2635 c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;2635 c->avg_h264_qpel_pixels_tab[1][x+y*4] = avg_h264_qpel8_mc##x##y##_##CPU;
2636 if((mm_flags & AV_CPU_FLAG_SSE2) && !(mm_flags & AV_CPU_FLAG_3DNOW)){2636 if((mm_flags & AV_CPU_FLAG_SSE2) && !(mm_flags & AV_CPU_FLAG_3DNOW)){
2637 // these functions are slower than mmx on AMD, but faster on Intel2637 // these functions are slower than mmx on AMD, but faster on Intel
2638 if (!h264_high_depth) {2638 if (!high_bit_depth) {
2639 c->put_pixels_tab[0][0] = put_pixels16_sse2;2639 c->put_pixels_tab[0][0] = put_pixels16_sse2;
2640 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_sse2;2640 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_sse2;
2641 c->avg_pixels_tab[0][0] = avg_pixels16_sse2;2641 c->avg_pixels_tab[0][0] = avg_pixels16_sse2;
@@ -2643,7 +2643,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 1 unmodified line
2643 }2643 }
2644 }2644 }
2645 if(mm_flags & AV_CPU_FLAG_SSE2){2645 if(mm_flags & AV_CPU_FLAG_SSE2){
2646 if (!h264_high_depth) {2646 if (!high_bit_depth) {
2647 H264_QPEL_FUNCS(0, 1, sse2);2647 H264_QPEL_FUNCS(0, 1, sse2);
2648 H264_QPEL_FUNCS(0, 2, sse2);2648 H264_QPEL_FUNCS(0, 2, sse2);
2649 H264_QPEL_FUNCS(0, 3, sse2);2649 H264_QPEL_FUNCS(0, 3, sse2);
@@ -2660,7 +2660,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 10 unmodified lines
2660 }2660 }
2661#if HAVE_SSSE32661#if HAVE_SSSE3
2662 if(mm_flags & AV_CPU_FLAG_SSSE3){2662 if(mm_flags & AV_CPU_FLAG_SSSE3){
2663 if (!h264_high_depth) {2663 if (!high_bit_depth) {
2664 H264_QPEL_FUNCS(1, 0, ssse3);2664 H264_QPEL_FUNCS(1, 0, ssse3);
2665 H264_QPEL_FUNCS(1, 1, ssse3);2665 H264_QPEL_FUNCS(1, 1, ssse3);
2666 H264_QPEL_FUNCS(1, 2, ssse3);2666 H264_QPEL_FUNCS(1, 2, ssse3);
@@ -2675,7 +2675,7 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx) · 8 unmodified lines
2675 H264_QPEL_FUNCS(3, 3, ssse3);2675 H264_QPEL_FUNCS(3, 3, ssse3);
2676 }2676 }
2677#if HAVE_YASM2677#if HAVE_YASM
2678 if (!h264_high_depth) {2678 if (!high_bit_depth) {
2679 c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd;2679 c->put_h264_chroma_pixels_tab[0]= ff_put_h264_chroma_mc8_ssse3_rnd;
2680 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_ssse3_rnd;2680 c->avg_h264_chroma_pixels_tab[0]= ff_avg_h264_chroma_mc8_ssse3_rnd;
2681 c->put_h264_chroma_pixels_tab[1]= ff_put_h264_chroma_mc4_ssse3;2681 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
2737 }2737 }
2738 }2738 }
2739 2739
2740 if (!h264_high_depth)2740 if (!high_bit_depth)
2741 c->emulated_edge_mc = emulated_edge_mc_sse;2741 c->emulated_edge_mc = emulated_edge_mc_sse;
2742 c->gmc= gmc_sse;2742 c->gmc= gmc_sse;
2743#endif2743#endif
libavformat/utils.c+5−5
@@ -3048,12 +3048,12 @@ static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacke · 3047 unmodified lines
3048{3048{
3049 AVStream *st = s->streams[ pkt ->stream_index];3049 AVStream *st = s->streams[ pkt ->stream_index];
3050 AVStream *st2= s->streams[ next->stream_index];3050 AVStream *st2= s->streams[ next->stream_index];
3051 int64_t a= st2->time_base.num * (int64_t)st ->time_base.den;3051 int comp = av_compare_ts(next->dts, st2->time_base, pkt->dts,
3052 int64_t b= st ->time_base.num * (int64_t)st2->time_base.den;3052 st->time_base);
3053 int64_t dts1 = av_rescale_rnd(pkt->dts, b, a, AV_ROUND_DOWN);3053
3054 if (dts1==next->dts && dts1==av_rescale_rnd(pkt->dts, b, a, AV_ROUND_UP))3054 if (comp == 0)
3055 return pkt->stream_index < next->stream_index;3055 return pkt->stream_index < next->stream_index;
3056 return dts1 < next->dts;3056 return comp > 0;
3057}3057}
3058 3058
3059int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){3059int 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
67 union {67 union {
68 double dbl;68 double dbl;
69 const char *str;69 const char *str;
70 /* TODO those are unused now */
71 int64_t i64;
72 AVRational q;
70 } default_val;73 } default_val;
71 double min; ///< minimum valid value for the option74 double min; ///< minimum valid value for the option
72 double max; ///< maximum valid value for the option75 double max; ///< maximum valid value for the option
libavutil/pixfmt.h+1−1
@@ -136,7 +136,7 @@ enum PixelFormat { · 135 unmodified lines
136 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-endian136 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
137 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-endian137 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
138 138
139 //the following 4 formats are deprecated and should be replaced by PIX_FMT_YUV420P16* with the bpp stored seperately139 //the following 6 formats are deprecated and should be replaced by PIX_FMT_YUV420P16* with the bpp stored seperately
140 PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian140 PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
141 PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian141 PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
142 PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian142 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
107 || (x)==PIX_FMT_YUV440P \107 || (x)==PIX_FMT_YUV440P \
108 || (x)==PIX_FMT_MONOWHITE \108 || (x)==PIX_FMT_MONOWHITE \
109 || (x)==PIX_FMT_MONOBLACK \109 || (x)==PIX_FMT_MONOBLACK \
110 || (x)==PIX_FMT_YUV420P9LE \
111 || (x)==PIX_FMT_YUV420P10LE \
110 || (x)==PIX_FMT_YUV420P16LE \112 || (x)==PIX_FMT_YUV420P16LE \
111 || (x)==PIX_FMT_YUV422P16LE \113 || (x)==PIX_FMT_YUV422P16LE \
112 || (x)==PIX_FMT_YUV444P16LE \114 || (x)==PIX_FMT_YUV444P16LE \
115 || (x)==PIX_FMT_YUV420P9BE \
116 || (x)==PIX_FMT_YUV420P10BE \
113 || (x)==PIX_FMT_YUV420P16BE \117 || (x)==PIX_FMT_YUV420P16BE \
114 || (x)==PIX_FMT_YUV422P16BE \118 || (x)==PIX_FMT_YUV422P16BE \
115 || (x)==PIX_FMT_YUV444P16BE \119 || (x)==PIX_FMT_YUV444P16BE \
tests/fate/h264.mak+14−0
@@ -127,6 +127,13 @@ FATE_H264 = aud_mw_e \ · 126 unmodified lines
127 frext-hpcvflnl_bcrm_a \127 frext-hpcvflnl_bcrm_a \
128 frext-hpcvmolq_brcm_b \128 frext-hpcvmolq_brcm_b \
129 frext-hpcvnl_brcm_a \129 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 \
130 hcbp2_hhi_a \137 hcbp2_hhi_a \
131 hcmp1_hhi_a \138 hcmp1_hhi_a \
132 ls_sva_d \139 ls_sva_d \
@@ -301,6 +308,13 @@ fate-h264-conformance-frext-hpcvfl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-co · 168 unmodified lines
301fate-h264-conformance-frext-hpcvflnl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVFLNL_BRCM_A.264 -vsync 0308fate-h264-conformance-frext-hpcvflnl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVFLNL_BRCM_A.264 -vsync 0
302fate-h264-conformance-frext-hpcvmolq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVMOLQ_BRCM_B.264309fate-h264-conformance-frext-hpcvmolq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVMOLQ_BRCM_B.264
303fate-h264-conformance-frext-hpcvnl_brcm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVNL_BRCM_A.264310fate-h264-conformance-frext-hpcvnl_brcm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVNL_BRCM_A.264
311fate-h264-conformance-frext-pph10i1_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I1_Panasonic_A.264
312fate-h264-conformance-frext-pph10i2_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I2_Panasonic_A.264
313fate-h264-conformance-frext-pph10i3_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I3_Panasonic_A.264
314fate-h264-conformance-frext-pph10i4_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I4_Panasonic_A.264
315fate-h264-conformance-frext-pph10i5_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I5_Panasonic_A.264
316fate-h264-conformance-frext-pph10i6_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I6_Panasonic_A.264
317fate-h264-conformance-frext-pph10i7_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I7_Panasonic_A.264
304fate-h264-conformance-hcbp2_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCBP2_HHI_A.264318fate-h264-conformance-hcbp2_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCBP2_HHI_A.264
305fate-h264-conformance-hcmp1_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCMP1_HHI_A.264319fate-h264-conformance-hcmp1_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCMP1_HHI_A.264
306fate-h264-conformance-ls_sva_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/LS_SVA_D.264320fate-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 @@
10, 0, 2764800, 0xcc4df07d
20, 3600, 2764800, 0x85f9e6d4
30, 7200, 2764800, 0x23ffe90d
40, 10800, 2764800, 0xf0a6d453
50, 14400, 2764800, 0x913a6392
60, 18000, 2764800, 0xcc5f9736
70, 21600, 2764800, 0x43f9f9ce
80, 25200, 2764800, 0xc874b44e
90, 28800, 2764800, 0x83b665e6
100, 32400, 2764800, 0x5ea2e31e
tests/ref/fate/h264-conformance-frext-pph10i2_panasonic_a+10−0
@@ -0,0 +1,10 @@
10, 0, 2764800, 0x4f710132
20, 3600, 2764800, 0x57e5b713
30, 7200, 2764800, 0xcca01477
40, 10800, 2764800, 0xa19a95cd
50, 14400, 2764800, 0x700a757d
60, 18000, 2764800, 0xd8c6f60f
70, 21600, 2764800, 0x95a1bbc7
80, 25200, 2764800, 0x0582077a
90, 28800, 2764800, 0x91595f91
100, 32400, 2764800, 0xf5fe034a
tests/ref/fate/h264-conformance-frext-pph10i3_panasonic_a+10−0
@@ -0,0 +1,10 @@
10, 0, 2764800, 0xda69f69e
20, 3600, 2764800, 0x29ed832f
30, 7200, 2764800, 0xb3244cc4
40, 10800, 2764800, 0xe41a312c
50, 14400, 2764800, 0xac0b344b
60, 18000, 2764800, 0xc585aa20
70, 21600, 2764800, 0x0952054c
80, 25200, 2764800, 0xd1a02f87
90, 28800, 2764800, 0xfcbfe87c
100, 32400, 2764800, 0xe4e9b8a2
tests/ref/fate/h264-conformance-frext-pph10i4_panasonic_a+19−0
@@ -0,0 +1,19 @@
10, 0, 6220800, 0xca2a2a5e
20, 3600, 6220800, 0x8009a65e
30, 7200, 6220800, 0x63e72b3b
40, 10800, 6220800, 0x7459a1cc
50, 14400, 6220800, 0x02191aa9
60, 18000, 6220800, 0x88dca590
70, 21600, 6220800, 0x56dd150a
80, 25200, 6220800, 0x5f56a56f
90, 28800, 6220800, 0x67ada4b7
100, 32400, 6220800, 0x88dca590
110, 36000, 6220800, 0xd3b09fe5
120, 39600, 6220800, 0x2223998c
130, 43200, 6220800, 0x5e5b2da5
140, 46800, 6220800, 0x88dca590
150, 50400, 6220800, 0x5e5b2da5
160, 54000, 6220800, 0x88dca590
170, 57600, 6220800, 0x5e5b2da5
180, 61200, 6220800, 0x88dca590
190, 64800, 6220800, 0x26e1ec8b
tests/ref/fate/h264-conformance-frext-pph10i5_panasonic_a+10−0
@@ -0,0 +1,10 @@
10, 0, 6220800, 0x1df58ce9
20, 3600, 6220800, 0x8f2859ce
30, 7200, 6220800, 0x229cc7ff
40, 10800, 6220800, 0x73e86984
50, 14400, 6220800, 0xb6d4504b
60, 18000, 6220800, 0x4e7d4883
70, 21600, 6220800, 0xbec3f0f7
80, 25200, 6220800, 0x1d9af065
90, 28800, 6220800, 0x44851549
100, 32400, 6220800, 0xfcf8728e
tests/ref/fate/h264-conformance-frext-pph10i6_panasonic_a+10−0
@@ -0,0 +1,10 @@
10, 0, 6220800, 0x408daf70
20, 3600, 6220800, 0x59b254a3
30, 7200, 6220800, 0x4cf4279c
40, 10800, 6220800, 0x5c9437ae
50, 14400, 6220800, 0x986c3eb8
60, 18000, 6220800, 0x23fd883e
70, 21600, 6220800, 0x84f222fe
80, 25200, 6220800, 0xe7f91107
90, 28800, 6220800, 0xb544b31e
100, 32400, 6220800, 0x1ebdde56
tests/ref/fate/h264-conformance-frext-pph10i7_panasonic_a+10−0
@@ -0,0 +1,10 @@
10, 0, 6220800, 0xf81873fe
20, 3600, 6220800, 0x7b96fbdc
30, 7200, 6220800, 0x75dbafc4
40, 10800, 6220800, 0x7524301e
50, 14400, 6220800, 0x0f3621ab
60, 18000, 6220800, 0xa5e25b35
70, 21600, 6220800, 0x063a8116
80, 25200, 6220800, 0x48ebc8ff
90, 28800, 6220800, 0x1f635df8
100, 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