Unified · Split
| @@ -54,6 +54,7 @@ easier to use. The changes are: · 53 unmodified lines | ||
| 54 | 54 | - boxblur filter |
| 55 | 55 | - Ut Video decoder |
| 56 | 56 | - Speex encoding via libspeex |
| 57 | +- 4:2:2 H.264 decoding support | |
| 57 | 58 | |
| 58 | 59 | |
| 59 | 60 | version 0.7: |
| @@ -92,7 +92,7 @@ void ff_h264_idct8_add4_neon(uint8_t *dst, const int *block_offset, · 91 unmodified lines | ||
| 92 | 92 | DCTELEM *block, int stride, |
| 93 | 93 | const uint8_t nnzc[6*8]); |
| 94 | 94 | |
| 95 | −static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth) | |
| 95 | +static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) | |
| 96 | 96 | { |
| 97 | 97 | if (bit_depth == 8) { |
| 98 | 98 | c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; |
| @@ -122,14 +122,15 @@ static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth) · 23 unmodified lines | ||
| 122 | 122 | c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; |
| 123 | 123 | c->h264_idct_add16 = ff_h264_idct_add16_neon; |
| 124 | 124 | c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; |
| 125 | − c->h264_idct_add8 = ff_h264_idct_add8_neon; | |
| 125 | + if (chroma_format_idc == 1) | |
| 126 | + c->h264_idct_add8 = ff_h264_idct_add8_neon; | |
| 126 | 127 | c->h264_idct8_add = ff_h264_idct8_add_neon; |
| 127 | 128 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; |
| 128 | 129 | c->h264_idct8_add4 = ff_h264_idct8_add4_neon; |
| 129 | 130 | } |
| 130 | 131 | } |
| 131 | 132 | |
| 132 | −void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth) | |
| 133 | +void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) | |
| 133 | 134 | { |
| 134 | − if (HAVE_NEON) ff_h264dsp_init_neon(c, bit_depth); | |
| 135 | + if (HAVE_NEON) ff_h264dsp_init_neon(c, bit_depth, chroma_format_idc); | |
| 135 | 136 | } |
| @@ -42,7 +42,7 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, int stride); · 41 unmodified lines | ||
| 42 | 42 | void ff_pred8x8_l00_dc_neon(uint8_t *src, int stride); |
| 43 | 43 | void ff_pred8x8_0l0_dc_neon(uint8_t *src, int stride); |
| 44 | 44 | |
| 45 | −static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int bit_depth) | |
| 45 | +static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) | |
| 46 | 46 | { |
| 47 | 47 | const int high_depth = bit_depth > 8; |
| 48 | 48 | |
| @@ -74,7 +74,7 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int b · 25 unmodified lines | ||
| 74 | 74 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | −void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth) | |
| 77 | +void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth, const int chroma_format_idc) | |
| 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, chroma_format_idc); | |
| 80 | 80 | } |
| @@ -63,8 +63,10 @@ void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int strid · 62 unmodified lines | ||
| 63 | 63 | void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ |
| 64 | 64 | void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ |
| 65 | 65 | void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ |
| 66 | +void ff_h264_idct_add8_422_ ## depth ## _c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | |
| 66 | 67 | void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ |
| 67 | 68 | void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(DCTELEM *output, DCTELEM *input, int qmul);\ |
| 69 | +void ff_h264_chroma422_dc_dequant_idct_ ## depth ## _c(DCTELEM *block, int qmul);\ | |
| 68 | 70 | void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(DCTELEM *block, int qmul); |
| 69 | 71 | |
| 70 | 72 | H264_IDCT( 8) |
| @@ -942,7 +942,7 @@ static void clone_tables(H264Context *dst, H264Context *src, int i){ · 941 unmodified lines | ||
| 942 | 942 | dst->list_counts = src->list_counts; |
| 943 | 943 | |
| 944 | 944 | dst->s.obmc_scratchpad = NULL; |
| 945 | − ff_h264_pred_init(&dst->hpc, src->s.codec_id, src->sps.bit_depth_luma); | |
| 945 | + ff_h264_pred_init(&dst->hpc, src->s.codec_id, src->sps.bit_depth_luma, src->sps.chroma_format_idc); | |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | /** |
| @@ -970,8 +970,8 @@ static av_cold void common_init(H264Context *h){ · 21 unmodified lines | ||
| 970 | 970 | s->height = s->avctx->height; |
| 971 | 971 | s->codec_id= s->avctx->codec->id; |
| 972 | 972 | |
| 973 | − ff_h264dsp_init(&h->h264dsp, 8); | |
| 974 | − ff_h264_pred_init(&h->hpc, s->codec_id, 8); | |
| 973 | + ff_h264dsp_init(&h->h264dsp, 8, 1); | |
| 974 | + ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1); | |
| 975 | 975 | |
| 976 | 976 | h->dequant_coeff_pps= -1; |
| 977 | 977 | s->unrestricted_mv=1; |
| @@ -1432,11 +1432,16 @@ static void decode_postinit(H264Context *h, int setup_finished){ · 454 unmodified lines | ||
| 1432 | 1432 | ff_thread_finish_setup(s->avctx); |
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | −static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int chroma444, int simple){ | |
| 1435 | +static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, | |
| 1436 | + uint8_t *src_cb, uint8_t *src_cr, | |
| 1437 | + int linesize, int uvlinesize, int simple) | |
| 1438 | +{ | |
| 1436 | 1439 | MpegEncContext * const s = &h->s; |
| 1437 | 1440 | uint8_t *top_border; |
| 1438 | 1441 | int top_idx = 1; |
| 1439 | 1442 | const int pixel_shift = h->pixel_shift; |
| 1443 | + int chroma444 = CHROMA444; | |
| 1444 | + int chroma422 = CHROMA422; | |
| 1440 | 1445 | |
| 1441 | 1446 | src_y -= linesize; |
| 1442 | 1447 | src_cb -= uvlinesize; |
| @@ -1460,6 +1465,14 @@ static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, ui · 17 unmodified lines | ||
| 1460 | 1465 | AV_COPY128(top_border+16, src_cb + 15*uvlinesize); |
| 1461 | 1466 | AV_COPY128(top_border+32, src_cr + 15*uvlinesize); |
| 1462 | 1467 | } |
| 1468 | + } else if(chroma422) { | |
| 1469 | + if (pixel_shift) { | |
| 1470 | + AV_COPY128(top_border+32, src_cb + 15*uvlinesize); | |
| 1471 | + AV_COPY128(top_border+48, src_cr + 15*uvlinesize); | |
| 1472 | + } else { | |
| 1473 | + AV_COPY64(top_border+16, src_cb + 15*uvlinesize); | |
| 1474 | + AV_COPY64(top_border+24, src_cr + 15*uvlinesize); | |
| 1475 | + } | |
| 1463 | 1476 | } else { |
| 1464 | 1477 | if (pixel_shift) { |
| 1465 | 1478 | AV_COPY128(top_border+32, src_cb+7*uvlinesize); |
| @@ -1495,6 +1508,14 @@ static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, ui · 29 unmodified lines | ||
| 1495 | 1508 | AV_COPY128(top_border+16, src_cb + 16*linesize); |
| 1496 | 1509 | AV_COPY128(top_border+32, src_cr + 16*linesize); |
| 1497 | 1510 | } |
| 1511 | + } else if(chroma422) { | |
| 1512 | + if (pixel_shift) { | |
| 1513 | + AV_COPY128(top_border+32, src_cb+16*uvlinesize); | |
| 1514 | + AV_COPY128(top_border+48, src_cr+16*uvlinesize); | |
| 1515 | + } else { | |
| 1516 | + AV_COPY64(top_border+16, src_cb+16*uvlinesize); | |
| 1517 | + AV_COPY64(top_border+24, src_cr+16*uvlinesize); | |
| 1518 | + } | |
| 1498 | 1519 | } else { |
| 1499 | 1520 | if (pixel_shift) { |
| 1500 | 1521 | AV_COPY128(top_border+32, src_cb+8*uvlinesize); |
| @@ -1773,10 +1794,11 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 272 unmodified lines | ||
| 1773 | 1794 | /* is_h264 should always be true if SVQ3 is disabled. */ |
| 1774 | 1795 | const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264; |
| 1775 | 1796 | void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); |
| 1797 | + const int block_h = 16 >> s->chroma_y_shift; | |
| 1776 | 1798 | |
| 1777 | 1799 | dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; |
| 1778 | − dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; | |
| 1779 | − dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; | |
| 1800 | + dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift)*8 + mb_y * s->uvlinesize * block_h; | |
| 1801 | + dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift)*8 + mb_y * s->uvlinesize * block_h; | |
| 1780 | 1802 | |
| 1781 | 1803 | s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4); |
| 1782 | 1804 | s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + (64 << pixel_shift), dest_cr - dest_cb, 2); |
| @@ -1789,8 +1811,8 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 6 unmodified lines | ||
| 1789 | 1811 | block_offset = &h->block_offset[48]; |
| 1790 | 1812 | if(mb_y&1){ //FIXME move out of this function? |
| 1791 | 1813 | dest_y -= s->linesize*15; |
| 1792 | − dest_cb-= s->uvlinesize*7; | |
| 1793 | − dest_cr-= s->uvlinesize*7; | |
| 1814 | + dest_cb-= s->uvlinesize * (block_h - 1); | |
| 1815 | + dest_cr-= s->uvlinesize * (block_h - 1); | |
| 1794 | 1816 | } |
| 1795 | 1817 | if(FRAME_MBAFF) { |
| 1796 | 1818 | int list; |
| @@ -1842,12 +1864,12 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 45 unmodified lines | ||
| 1842 | 1864 | } |
| 1843 | 1865 | } |
| 1844 | 1866 | } else { |
| 1845 | − for (i = 0; i < 8; i++) { | |
| 1867 | + for (i = 0; i < block_h; i++) { | |
| 1846 | 1868 | uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize); |
| 1847 | 1869 | for (j = 0; j < 8; j++) |
| 1848 | 1870 | tmp_cb[j] = get_bits(&gb, bit_depth); |
| 1849 | 1871 | } |
| 1850 | − for (i = 0; i < 8; i++) { | |
| 1872 | + for (i = 0; i < block_h; i++) { | |
| 1851 | 1873 | uint16_t *tmp_cr = (uint16_t*)(dest_cr + i*uvlinesize); |
| 1852 | 1874 | for (j = 0; j < 8; j++) |
| 1853 | 1875 | tmp_cr[j] = get_bits(&gb, bit_depth); |
| @@ -1865,7 +1887,7 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 11 unmodified lines | ||
| 1865 | 1887 | memset(dest_cr + i*uvlinesize, 128, 8); |
| 1866 | 1888 | } |
| 1867 | 1889 | } else { |
| 1868 | − for (i = 0; i < 8; i++) { | |
| 1890 | + for (i = 0; i < block_h; i++) { | |
| 1869 | 1891 | memcpy(dest_cb + i*uvlinesize, h->mb + 128 + i*4, 8); |
| 1870 | 1892 | memcpy(dest_cr + i*uvlinesize, h->mb + 160 + i*4, 8); |
| 1871 | 1893 | } |
| @@ -1913,10 +1935,18 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 41 unmodified lines | ||
| 1913 | 1935 | } |
| 1914 | 1936 | }else{ |
| 1915 | 1937 | if(is_h264){ |
| 1938 | + int qp[2]; | |
| 1939 | + if (CHROMA422) { | |
| 1940 | + qp[0] = h->chroma_qp[0] + 3; | |
| 1941 | + qp[1] = h->chroma_qp[1] + 3; | |
| 1942 | + } else { | |
| 1943 | + qp[0] = h->chroma_qp[0]; | |
| 1944 | + qp[1] = h->chroma_qp[1]; | |
| 1945 | + } | |
| 1916 | 1946 | if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ]) |
| 1917 | − h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16*1 << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]); | |
| 1947 | + h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16*1 << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][qp[0]][0]); | |
| 1918 | 1948 | if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ]) |
| 1919 | − h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16*2 << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]); | |
| 1949 | + h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16*16*2 << pixel_shift), h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][qp[1]][0]); | |
| 1920 | 1950 | h->h264dsp.h264_idct_add8(dest, block_offset, |
| 1921 | 1951 | h->mb, uvlinesize, |
| 1922 | 1952 | h->non_zero_count_cache); |
| @@ -2555,11 +2585,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ · 632 unmodified lines | ||
| 2555 | 2585 | |
| 2556 | 2586 | h->b_stride= s->mb_width*4; |
| 2557 | 2587 | |
| 2588 | + s->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p | |
| 2589 | + | |
| 2558 | 2590 | s->width = 16*s->mb_width - (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1); |
| 2559 | 2591 | if(h->sps.frame_mbs_only_flag) |
| 2560 | − s->height= 16*s->mb_height - (2>>CHROMA444)*FFMIN(h->sps.crop_bottom, (8<<CHROMA444)-1); | |
| 2592 | + s->height= 16*s->mb_height - (1<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1); | |
| 2561 | 2593 | else |
| 2562 | − s->height= 16*s->mb_height - (4>>CHROMA444)*FFMIN(h->sps.crop_bottom, (8<<CHROMA444)-1); | |
| 2594 | + s->height= 16*s->mb_height - (2<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1); | |
| 2563 | 2595 | |
| 2564 | 2596 | if (s->context_initialized |
| 2565 | 2597 | && ( s->width != s->avctx->width || s->height != s->avctx->height |
| @@ -2601,14 +2633,26 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ · 35 unmodified lines | ||
| 2601 | 2633 | |
| 2602 | 2634 | switch (h->sps.bit_depth_luma) { |
| 2603 | 2635 | case 9 : |
| 2604 | − s->avctx->pix_fmt = CHROMA444 ? PIX_FMT_YUV444P9 : PIX_FMT_YUV420P9; | |
| 2636 | + if (CHROMA444) | |
| 2637 | + s->avctx->pix_fmt = PIX_FMT_YUV444P9; | |
| 2638 | + else if (CHROMA422) | |
| 2639 | + s->avctx->pix_fmt = PIX_FMT_YUV422P9; | |
| 2640 | + else | |
| 2641 | + s->avctx->pix_fmt = PIX_FMT_YUV420P9; | |
| 2605 | 2642 | break; |
| 2606 | 2643 | case 10 : |
| 2607 | − s->avctx->pix_fmt = CHROMA444 ? PIX_FMT_YUV444P10 : PIX_FMT_YUV420P10; | |
| 2644 | + if (CHROMA444) | |
| 2645 | + s->avctx->pix_fmt = PIX_FMT_YUV444P10; | |
| 2646 | + else if (CHROMA422) | |
| 2647 | + s->avctx->pix_fmt = PIX_FMT_YUV422P10; | |
| 2648 | + else | |
| 2649 | + s->avctx->pix_fmt = PIX_FMT_YUV420P10; | |
| 2608 | 2650 | break; |
| 2609 | 2651 | default: |
| 2610 | 2652 | if (CHROMA444){ |
| 2611 | 2653 | s->avctx->pix_fmt = s->avctx->color_range == AVCOL_RANGE_JPEG ? PIX_FMT_YUVJ444P : PIX_FMT_YUV444P; |
| 2654 | + } else if (CHROMA422) { | |
| 2655 | + s->avctx->pix_fmt = s->avctx->color_range == AVCOL_RANGE_JPEG ? PIX_FMT_YUVJ422P : PIX_FMT_YUV422P; | |
| 2612 | 2656 | }else{ |
| 2613 | 2657 | s->avctx->pix_fmt = s->avctx->get_format(s->avctx, |
| 2614 | 2658 | s->avctx->codec->pix_fmts ? |
| @@ -3272,6 +3316,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ · 657 unmodified lines | ||
| 3272 | 3316 | const int end_mb_y= s->mb_y + FRAME_MBAFF; |
| 3273 | 3317 | const int old_slice_type= h->slice_type; |
| 3274 | 3318 | const int pixel_shift = h->pixel_shift; |
| 3319 | + const int block_h = 16 >> s->chroma_y_shift; | |
| 3275 | 3320 | |
| 3276 | 3321 | if(h->deblocking_filter) { |
| 3277 | 3322 | for(mb_x= start_x; mb_x<end_x; mb_x++){ |
| @@ -3288,8 +3333,8 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ · 10 unmodified lines | ||
| 3288 | 3333 | s->mb_x= mb_x; |
| 3289 | 3334 | s->mb_y= mb_y; |
| 3290 | 3335 | dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; |
| 3291 | − dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444); | |
| 3292 | − dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444); | |
| 3336 | + dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h; | |
| 3337 | + dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h; | |
| 3293 | 3338 | //FIXME simplify above |
| 3294 | 3339 | |
| 3295 | 3340 | if (MB_FIELD) { |
| @@ -3297,14 +3342,14 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ · 1 unmodified line | ||
| 3297 | 3342 | uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2; |
| 3298 | 3343 | if(mb_y&1){ //FIXME move out of this function? |
| 3299 | 3344 | dest_y -= s->linesize*15; |
| 3300 | − dest_cb-= s->uvlinesize*((8 << CHROMA444)-1); | |
| 3301 | − dest_cr-= s->uvlinesize*((8 << CHROMA444)-1); | |
| 3345 | + dest_cb-= s->uvlinesize * (block_h - 1); | |
| 3346 | + dest_cr-= s->uvlinesize * (block_h - 1); | |
| 3302 | 3347 | } |
| 3303 | 3348 | } else { |
| 3304 | 3349 | linesize = h->mb_linesize = s->linesize; |
| 3305 | 3350 | uvlinesize = h->mb_uvlinesize = s->uvlinesize; |
| 3306 | 3351 | } |
| 3307 | − backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, CHROMA444, 0); | |
| 3352 | + backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0); | |
| 3308 | 3353 | if(fill_filter_caches(h, mb_type)) |
| 3309 | 3354 | continue; |
| 3310 | 3355 | h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mb_xy]); |
| @@ -3742,13 +3787,15 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ · 431 unmodified lines | ||
| 3742 | 3787 | if(avctx->has_b_frames < 2) |
| 3743 | 3788 | avctx->has_b_frames= !s->low_delay; |
| 3744 | 3789 | |
| 3745 | − if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma) { | |
| 3790 | + if (avctx->bits_per_raw_sample != h->sps.bit_depth_luma || | |
| 3791 | + h->cur_chroma_format_idc != h->sps.chroma_format_idc) { | |
| 3746 | 3792 | if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) { |
| 3747 | 3793 | avctx->bits_per_raw_sample = h->sps.bit_depth_luma; |
| 3794 | + h->cur_chroma_format_idc = h->sps.chroma_format_idc; | |
| 3748 | 3795 | h->pixel_shift = h->sps.bit_depth_luma > 8; |
| 3749 | 3796 | |
| 3750 | − ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma); | |
| 3751 | − ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma); | |
| 3797 | + ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma, h->sps.chroma_format_idc); | |
| 3798 | + ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma, h->sps.chroma_format_idc); | |
| 3752 | 3799 | s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16; |
| 3753 | 3800 | dsputil_init(&s->dsp, s->avctx); |
| 3754 | 3801 | } else { |
| @@ -39,13 +39,6 @@ · 38 unmodified lines | ||
| 39 | 39 | #define interlaced_dct interlaced_dct_is_a_bad_name |
| 40 | 40 | #define mb_intra mb_intra_is_not_initialized_see_mb_type |
| 41 | 41 | |
| 42 | −#define CHROMA_DC_COEFF_TOKEN_VLC_BITS 8 | |
| 43 | −#define COEFF_TOKEN_VLC_BITS 8 | |
| 44 | −#define TOTAL_ZEROS_VLC_BITS 9 | |
| 45 | −#define CHROMA_DC_TOTAL_ZEROS_VLC_BITS 3 | |
| 46 | −#define RUN_VLC_BITS 3 | |
| 47 | −#define RUN7_VLC_BITS 6 | |
| 48 | − | |
| 49 | 42 | #define MAX_SPS_COUNT 32 |
| 50 | 43 | #define MAX_PPS_COUNT 256 |
| 51 | 44 | |
| @@ -92,6 +85,7 @@ · 40 unmodified lines | ||
| 92 | 85 | #define CABAC h->pps.cabac |
| 93 | 86 | #endif |
| 94 | 87 | |
| 88 | +#define CHROMA422 (h->sps.chroma_format_idc == 2) | |
| 95 | 89 | #define CHROMA444 (h->sps.chroma_format_idc == 3) |
| 96 | 90 | |
| 97 | 91 | #define EXTENDED_SAR 255 |
| @@ -582,6 +576,8 @@ typedef struct H264Context{ · 484 unmodified lines | ||
| 582 | 576 | // Timestamp stuff |
| 583 | 577 | int sei_buffering_period_present; ///< Buffering period SEI flag |
| 584 | 578 | int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs |
| 579 | + | |
| 580 | + int cur_chroma_format_idc; | |
| 585 | 581 | }H264Context; |
| 586 | 582 | |
| 587 | 583 | |
| @@ -809,7 +805,7 @@ static av_always_inline void write_back_non_zero_count(H264Context *h){ · 221 unmodified lines | ||
| 809 | 805 | AV_COPY32(&nnz[32], &nnz_cache[4+8*11]); |
| 810 | 806 | AV_COPY32(&nnz[36], &nnz_cache[4+8*12]); |
| 811 | 807 | |
| 812 | − if(CHROMA444){ | |
| 808 | + if(!h->s.chroma_y_shift){ | |
| 813 | 809 | AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]); |
| 814 | 810 | AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]); |
| 815 | 811 | AV_COPY32(&nnz[40], &nnz_cache[4+8*13]); |
| @@ -1565,7 +1565,12 @@ DECLARE_ASM_CONST(1, uint8_t, last_coeff_flag_offset_8x8)[63] = { · 1564 unmodified lines | ||
| 1565 | 1565 | 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8 |
| 1566 | 1566 | }; |
| 1567 | 1567 | |
| 1568 | −static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff, int is_dc ) { | |
| 1568 | +static av_always_inline void | |
| 1569 | +decode_cabac_residual_internal(H264Context *h, DCTELEM *block, | |
| 1570 | + int cat, int n, const uint8_t *scantable, | |
| 1571 | + const uint32_t *qmul, int max_coeff, | |
| 1572 | + int is_dc, int chroma422) | |
| 1573 | +{ | |
| 1569 | 1574 | static const int significant_coeff_flag_offset[2][14] = { |
| 1570 | 1575 | { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718 }, |
| 1571 | 1576 | { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733 } |
| @@ -1587,12 +1592,16 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 15 unmodified lines | ||
| 1587 | 1592 | 9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9, |
| 1588 | 1593 | 9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 } |
| 1589 | 1594 | }; |
| 1595 | + static const uint8_t sig_coeff_offset_dc[7] = { 0, 0, 1, 1, 2, 2, 2 }; | |
| 1590 | 1596 | /* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0). |
| 1591 | 1597 | * 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter). |
| 1592 | 1598 | * map node ctx => cabac ctx for level=1 */ |
| 1593 | 1599 | static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 }; |
| 1594 | 1600 | /* map node ctx => cabac ctx for level>1 */ |
| 1595 | − static const uint8_t coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 }; | |
| 1601 | + static const uint8_t coeff_abs_levelgt1_ctx[2][8] = { | |
| 1602 | + { 5, 5, 5, 5, 6, 7, 8, 9 }, | |
| 1603 | + { 5, 5, 5, 5, 6, 7, 8, 8 }, // 422/dc case | |
| 1604 | + }; | |
| 1596 | 1605 | static const uint8_t coeff_abs_level_transition[2][8] = { |
| 1597 | 1606 | /* update node ctx after decoding a level=1 */ |
| 1598 | 1607 | { 1, 2, 3, 3, 4, 5, 6, 7 }, |
| @@ -1651,12 +1660,20 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 52 unmodified lines | ||
| 1651 | 1660 | coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, |
| 1652 | 1661 | last_coeff_ctx_base, sig_off); |
| 1653 | 1662 | } else { |
| 1654 | − coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, | |
| 1655 | − last_coeff_ctx_base-significant_coeff_ctx_base); | |
| 1663 | + if (is_dc && chroma422) { // dc 422 | |
| 1664 | + DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); | |
| 1665 | + } else { | |
| 1666 | + coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, | |
| 1667 | + last_coeff_ctx_base-significant_coeff_ctx_base); | |
| 1668 | + } | |
| 1656 | 1669 | #else |
| 1657 | 1670 | DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] ); |
| 1658 | 1671 | } else { |
| 1659 | − DECODE_SIGNIFICANCE( max_coeff - 1, last, last ); | |
| 1672 | + if (is_dc && chroma422) { // dc 422 | |
| 1673 | + DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); | |
| 1674 | + } else { | |
| 1675 | + DECODE_SIGNIFICANCE(max_coeff - 1, last, last); | |
| 1676 | + } | |
| 1660 | 1677 | #endif |
| 1661 | 1678 | } |
| 1662 | 1679 | assert(coeff_count > 0); |
| @@ -1691,7 +1708,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 28 unmodified lines | ||
| 1691 | 1708 | } \ |
| 1692 | 1709 | } else { \ |
| 1693 | 1710 | int coeff_abs = 2; \ |
| 1694 | − ctx = coeff_abs_levelgt1_ctx[node_ctx] + abs_level_m1_ctx_base; \ | |
| 1711 | + ctx = coeff_abs_levelgt1_ctx[is_dc && chroma422][node_ctx] + abs_level_m1_ctx_base; \ | |
| 1695 | 1712 | node_ctx = coeff_abs_level_transition[1][node_ctx]; \ |
| 1696 | 1713 | \ |
| 1697 | 1714 | while( coeff_abs < 15 && get_cabac( CC, ctx ) ) { \ |
| @@ -1733,11 +1750,18 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 35 unmodified lines | ||
| 1733 | 1750 | } |
| 1734 | 1751 | |
| 1735 | 1752 | static void decode_cabac_residual_dc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) { |
| 1736 | − decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1); | |
| 1753 | + decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 0); | |
| 1754 | +} | |
| 1755 | + | |
| 1756 | +static void decode_cabac_residual_dc_internal_422(H264Context *h, DCTELEM *block, | |
| 1757 | + int cat, int n, const uint8_t *scantable, | |
| 1758 | + int max_coeff) | |
| 1759 | +{ | |
| 1760 | + decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 1); | |
| 1737 | 1761 | } |
| 1738 | 1762 | |
| 1739 | 1763 | static void decode_cabac_residual_nondc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { |
| 1740 | − decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0); | |
| 1764 | + decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0, 0); | |
| 1741 | 1765 | } |
| 1742 | 1766 | |
| 1743 | 1767 | /* cat: 0-> DC 16x16 n = 0 |
| @@ -1761,6 +1785,19 @@ static av_always_inline void decode_cabac_residual_dc( H264Context *h, DCTELEM * · 17 unmodified lines | ||
| 1761 | 1785 | decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff ); |
| 1762 | 1786 | } |
| 1763 | 1787 | |
| 1788 | +static av_always_inline void | |
| 1789 | +decode_cabac_residual_dc_422(H264Context *h, DCTELEM *block, | |
| 1790 | + int cat, int n, const uint8_t *scantable, | |
| 1791 | + int max_coeff) | |
| 1792 | +{ | |
| 1793 | + /* read coded block flag */ | |
| 1794 | + if (get_cabac(&h->cabac, &h->cabac_state[get_cabac_cbf_ctx(h, cat, n, max_coeff, 1)]) == 0) { | |
| 1795 | + h->non_zero_count_cache[scan8[n]] = 0; | |
| 1796 | + return; | |
| 1797 | + } | |
| 1798 | + decode_cabac_residual_dc_internal_422(h, block, cat, n, scantable, max_coeff); | |
| 1799 | +} | |
| 1800 | + | |
| 1764 | 1801 | static av_always_inline void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { |
| 1765 | 1802 | /* read coded block flag */ |
| 1766 | 1803 | if( (cat != 5 || CHROMA444) && get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 0 ) ] ) == 0 ) { |
| @@ -2313,7 +2350,36 @@ decode_intra_mb: · 546 unmodified lines | ||
| 2313 | 2350 | if(CHROMA444){ |
| 2314 | 2351 | decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1); |
| 2315 | 2352 | decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2); |
| 2316 | − } else { | |
| 2353 | + } else if (CHROMA422) { | |
| 2354 | + if( cbp&0x30 ){ | |
| 2355 | + int c; | |
| 2356 | + for( c = 0; c < 2; c++ ) { | |
| 2357 | + //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c ); | |
| 2358 | + decode_cabac_residual_dc_422(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, | |
| 2359 | + CHROMA_DC_BLOCK_INDEX + c, | |
| 2360 | + chroma422_dc_scan, 8); | |
| 2361 | + } | |
| 2362 | + } | |
| 2363 | + | |
| 2364 | + if( cbp&0x20 ) { | |
| 2365 | + int c, i, i8x8; | |
| 2366 | + for( c = 0; c < 2; c++ ) { | |
| 2367 | + DCTELEM *mb = h->mb + (16*(16 + 16*c) << pixel_shift); | |
| 2368 | + qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; | |
| 2369 | + for (i8x8 = 0; i8x8 < 2; i8x8++) { | |
| 2370 | + for (i = 0; i < 4; i++) { | |
| 2371 | + const int index = 16 + 16 * c + 8*i8x8 + i; | |
| 2372 | + //av_log(s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16); | |
| 2373 | + decode_cabac_residual_nondc(h, mb, 4, index, scan + 1, qmul, 15); | |
| 2374 | + mb += 16<<pixel_shift; | |
| 2375 | + } | |
| 2376 | + } | |
| 2377 | + } | |
| 2378 | + } else { | |
| 2379 | + fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); | |
| 2380 | + fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); | |
| 2381 | + } | |
| 2382 | + } else /* yuv420 */ { | |
| 2317 | 2383 | if( cbp&0x30 ){ |
| 2318 | 2384 | int c; |
| 2319 | 2385 | for( c = 0; c < 2; c++ ) { |
| @@ -62,6 +62,30 @@ static const uint8_t chroma_dc_coeff_token_bits[4*5]={ · 61 unmodified lines | ||
| 62 | 62 | 2, 3, 2, 0, |
| 63 | 63 | }; |
| 64 | 64 | |
| 65 | +static const uint8_t chroma422_dc_coeff_token_len[4*9]={ | |
| 66 | + 1, 0, 0, 0, | |
| 67 | + 7, 2, 0, 0, | |
| 68 | + 7, 7, 3, 0, | |
| 69 | + 9, 7, 7, 5, | |
| 70 | + 9, 9, 7, 6, | |
| 71 | + 10, 10, 9, 7, | |
| 72 | + 11, 11, 10, 7, | |
| 73 | + 12, 12, 11, 10, | |
| 74 | + 13, 12, 12, 11, | |
| 75 | +}; | |
| 76 | + | |
| 77 | +static const uint8_t chroma422_dc_coeff_token_bits[4*9]={ | |
| 78 | + 1, 0, 0, 0, | |
| 79 | + 15, 1, 0, 0, | |
| 80 | + 14, 13, 1, 0, | |
| 81 | + 7, 12, 11, 1, | |
| 82 | + 6, 5, 10, 1, | |
| 83 | + 7, 6, 4, 9, | |
| 84 | + 7, 6, 5, 8, | |
| 85 | + 7, 6, 5, 4, | |
| 86 | + 7, 5, 4, 4, | |
| 87 | +}; | |
| 88 | + | |
| 65 | 89 | static const uint8_t coeff_token_len[4][4*17]={ |
| 66 | 90 | { |
| 67 | 91 | 1, 0, 0, 0, |
| @@ -172,6 +196,26 @@ static const uint8_t chroma_dc_total_zeros_bits[3][4]= { · 104 unmodified lines | ||
| 172 | 196 | { 1, 0, 0, 0,}, |
| 173 | 197 | }; |
| 174 | 198 | |
| 199 | +static const uint8_t chroma422_dc_total_zeros_len[7][8]= { | |
| 200 | + { 1, 3, 3, 4, 4, 4, 5, 5 }, | |
| 201 | + { 3, 2, 3, 3, 3, 3, 3 }, | |
| 202 | + { 3, 3, 2, 2, 3, 3 }, | |
| 203 | + { 3, 2, 2, 2, 3 }, | |
| 204 | + { 2, 2, 2, 2 }, | |
| 205 | + { 2, 2, 1 }, | |
| 206 | + { 1, 1 }, | |
| 207 | +}; | |
| 208 | + | |
| 209 | +static const uint8_t chroma422_dc_total_zeros_bits[7][8]= { | |
| 210 | + { 1, 2, 3, 2, 3, 1, 1, 0 }, | |
| 211 | + { 0, 1, 1, 4, 5, 6, 7 }, | |
| 212 | + { 0, 1, 1, 2, 6, 7 }, | |
| 213 | + { 6, 0, 1, 2, 7 }, | |
| 214 | + { 0, 1, 2, 3 }, | |
| 215 | + { 0, 1, 1 }, | |
| 216 | + { 0, 1 }, | |
| 217 | +}; | |
| 218 | + | |
| 175 | 219 | static const uint8_t run_len[7][16]={ |
| 176 | 220 | {1,1}, |
| 177 | 221 | {1,2,2}, |
| @@ -200,6 +244,10 @@ static VLC chroma_dc_coeff_token_vlc; · 22 unmodified lines | ||
| 200 | 244 | static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2]; |
| 201 | 245 | static const int chroma_dc_coeff_token_vlc_table_size = 256; |
| 202 | 246 | |
| 247 | +static VLC chroma422_dc_coeff_token_vlc; | |
| 248 | +static VLC_TYPE chroma422_dc_coeff_token_vlc_table[8192][2]; | |
| 249 | +static const int chroma422_dc_coeff_token_vlc_table_size = 8192; | |
| 250 | + | |
| 203 | 251 | static VLC total_zeros_vlc[15]; |
| 204 | 252 | static VLC_TYPE total_zeros_vlc_tables[15][512][2]; |
| 205 | 253 | static const int total_zeros_vlc_tables_size = 512; |
| @@ -208,6 +256,10 @@ static VLC chroma_dc_total_zeros_vlc[3]; · 2 unmodified lines | ||
| 208 | 256 | static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2]; |
| 209 | 257 | static const int chroma_dc_total_zeros_vlc_tables_size = 8; |
| 210 | 258 | |
| 259 | +static VLC chroma422_dc_total_zeros_vlc[7]; | |
| 260 | +static VLC_TYPE chroma422_dc_total_zeros_vlc_tables[7][32][2]; | |
| 261 | +static const int chroma422_dc_total_zeros_vlc_tables_size = 32; | |
| 262 | + | |
| 211 | 263 | static VLC run_vlc[6]; |
| 212 | 264 | static VLC_TYPE run_vlc_tables[6][8][2]; |
| 213 | 265 | static const int run_vlc_tables_size = 8; |
| @@ -219,6 +271,14 @@ static const int run7_vlc_table_size = 96; · 5 unmodified lines | ||
| 219 | 271 | #define LEVEL_TAB_BITS 8 |
| 220 | 272 | static int8_t cavlc_level_tab[7][1<<LEVEL_TAB_BITS][2]; |
| 221 | 273 | |
| 274 | +#define CHROMA_DC_COEFF_TOKEN_VLC_BITS 8 | |
| 275 | +#define CHROMA422_DC_COEFF_TOKEN_VLC_BITS 13 | |
| 276 | +#define COEFF_TOKEN_VLC_BITS 8 | |
| 277 | +#define TOTAL_ZEROS_VLC_BITS 9 | |
| 278 | +#define CHROMA_DC_TOTAL_ZEROS_VLC_BITS 3 | |
| 279 | +#define CHROMA422_DC_TOTAL_ZEROS_VLC_BITS 5 | |
| 280 | +#define RUN_VLC_BITS 3 | |
| 281 | +#define RUN7_VLC_BITS 6 | |
| 222 | 282 | |
| 223 | 283 | /** |
| 224 | 284 | * gets the predicted number of non-zero coefficients. |
| @@ -278,6 +338,13 @@ av_cold void ff_h264_decode_init_vlc(void){ · 53 unmodified lines | ||
| 278 | 338 | &chroma_dc_coeff_token_bits[0], 1, 1, |
| 279 | 339 | INIT_VLC_USE_NEW_STATIC); |
| 280 | 340 | |
| 341 | + chroma422_dc_coeff_token_vlc.table = chroma422_dc_coeff_token_vlc_table; | |
| 342 | + chroma422_dc_coeff_token_vlc.table_allocated = chroma422_dc_coeff_token_vlc_table_size; | |
| 343 | + init_vlc(&chroma422_dc_coeff_token_vlc, CHROMA422_DC_COEFF_TOKEN_VLC_BITS, 4*9, | |
| 344 | + &chroma422_dc_coeff_token_len [0], 1, 1, | |
| 345 | + &chroma422_dc_coeff_token_bits[0], 1, 1, | |
| 346 | + INIT_VLC_USE_NEW_STATIC); | |
| 347 | + | |
| 281 | 348 | offset = 0; |
| 282 | 349 | for(i=0; i<4; i++){ |
| 283 | 350 | coeff_token_vlc[i].table = coeff_token_vlc_tables+offset; |
| @@ -304,6 +371,17 @@ av_cold void ff_h264_decode_init_vlc(void){ · 20 unmodified lines | ||
| 304 | 371 | &chroma_dc_total_zeros_bits[i][0], 1, 1, |
| 305 | 372 | INIT_VLC_USE_NEW_STATIC); |
| 306 | 373 | } |
| 374 | + | |
| 375 | + for(i=0; i<7; i++){ | |
| 376 | + chroma422_dc_total_zeros_vlc[i].table = chroma422_dc_total_zeros_vlc_tables[i]; | |
| 377 | + chroma422_dc_total_zeros_vlc[i].table_allocated = chroma422_dc_total_zeros_vlc_tables_size; | |
| 378 | + init_vlc(&chroma422_dc_total_zeros_vlc[i], | |
| 379 | + CHROMA422_DC_TOTAL_ZEROS_VLC_BITS, 8, | |
| 380 | + &chroma422_dc_total_zeros_len [i][0], 1, 1, | |
| 381 | + &chroma422_dc_total_zeros_bits[i][0], 1, 1, | |
| 382 | + INIT_VLC_USE_NEW_STATIC); | |
| 383 | + } | |
| 384 | + | |
| 307 | 385 | for(i=0; i<15; i++){ |
| 308 | 386 | total_zeros_vlc[i].table = total_zeros_vlc_tables[i]; |
| 309 | 387 | total_zeros_vlc[i].table_allocated = total_zeros_vlc_tables_size; |
| @@ -373,7 +451,10 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in · 63 unmodified lines | ||
| 373 | 451 | //FIXME put trailing_onex into the context |
| 374 | 452 | |
| 375 | 453 | if(max_coeff <= 8){ |
| 376 | − coeff_token= get_vlc2(gb, chroma_dc_coeff_token_vlc.table, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 1); | |
| 454 | + if (max_coeff == 4) | |
| 455 | + coeff_token = get_vlc2(gb, chroma_dc_coeff_token_vlc.table, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 1); | |
| 456 | + else | |
| 457 | + coeff_token = get_vlc2(gb, chroma422_dc_coeff_token_vlc.table, CHROMA422_DC_COEFF_TOKEN_VLC_BITS, 1); | |
| 377 | 458 | total_coeff= coeff_token>>2; |
| 378 | 459 | }else{ |
| 379 | 460 | if(n >= LUMA_DC_BLOCK_INDEX){ |
| @@ -483,11 +564,16 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in · 103 unmodified lines | ||
| 483 | 564 | if(total_coeff == max_coeff) |
| 484 | 565 | zeros_left=0; |
| 485 | 566 | else{ |
| 486 | − /* FIXME: we don't actually support 4:2:2 yet. */ | |
| 487 | − if(max_coeff <= 8) | |
| 488 | − zeros_left= get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[ total_coeff ].table, CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1); | |
| 489 | − else | |
| 567 | + if (max_coeff <= 8) { | |
| 568 | + if (max_coeff == 4) | |
| 569 | + zeros_left = get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[total_coeff].table, | |
| 570 | + CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1); | |
| 571 | + else | |
| 572 | + zeros_left = get_vlc2(gb, (chroma422_dc_total_zeros_vlc-1)[total_coeff].table, | |
| 573 | + CHROMA422_DC_TOTAL_ZEROS_VLC_BITS, 1); | |
| 574 | + } else { | |
| 490 | 575 | zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1); |
| 576 | + } | |
| 491 | 577 | } |
| 492 | 578 | |
| 493 | 579 | #define STORE_BLOCK(type) \ |
| @@ -994,7 +1080,7 @@ decode_intra_mb: · 500 unmodified lines | ||
| 994 | 1080 | s->current_picture.f.mb_type[mb_xy] = mb_type; |
| 995 | 1081 | |
| 996 | 1082 | if(cbp || IS_INTRA16x16(mb_type)){ |
| 997 | − int i4x4, chroma_idx; | |
| 1083 | + int i4x4, i8x8, chroma_idx; | |
| 998 | 1084 | int dquant; |
| 999 | 1085 | int ret; |
| 1000 | 1086 | GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr; |
| @@ -1036,7 +1122,34 @@ decode_intra_mb: · 35 unmodified lines | ||
| 1036 | 1122 | if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ){ |
| 1037 | 1123 | return -1; |
| 1038 | 1124 | } |
| 1039 | − } else { | |
| 1125 | + } else if (CHROMA422) { | |
| 1126 | + if(cbp&0x30){ | |
| 1127 | + for(chroma_idx=0; chroma_idx<2; chroma_idx++) | |
| 1128 | + if (decode_residual(h, gb, h->mb + ((256 + 16*16*chroma_idx) << pixel_shift), | |
| 1129 | + CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma422_dc_scan, | |
| 1130 | + NULL, 8) < 0) { | |
| 1131 | + return -1; | |
| 1132 | + } | |
| 1133 | + } | |
| 1134 | + | |
| 1135 | + if(cbp&0x20){ | |
| 1136 | + for(chroma_idx=0; chroma_idx<2; chroma_idx++){ | |
| 1137 | + const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]]; | |
| 1138 | + DCTELEM *mb = h->mb + (16*(16 + 16*chroma_idx) << pixel_shift); | |
| 1139 | + for (i8x8 = 0; i8x8 < 2; i8x8++) { | |
| 1140 | + for (i4x4 = 0; i4x4 < 4; i4x4++) { | |
| 1141 | + const int index = 16 + 16*chroma_idx + 8*i8x8 + i4x4; | |
| 1142 | + if (decode_residual(h, gb, mb, index, scan + 1, qmul, 15) < 0) | |
| 1143 | + return -1; | |
| 1144 | + mb += 16 << pixel_shift; | |
| 1145 | + } | |
| 1146 | + } | |
| 1147 | + } | |
| 1148 | + }else{ | |
| 1149 | + fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); | |
| 1150 | + fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); | |
| 1151 | + } | |
| 1152 | + } else /* yuv420 */ { | |
| 1040 | 1153 | if(cbp&0x30){ |
| 1041 | 1154 | for(chroma_idx=0; chroma_idx<2; chroma_idx++) |
| 1042 | 1155 | if( decode_residual(h, gb, h->mb + ((256 + 16*16*chroma_idx) << pixel_shift), CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma_dc_scan, NULL, 4) < 0){ |
| @@ -212,6 +212,7 @@ static void av_always_inline h264_filter_mb_fast_internal( H264Context *h, int m · 211 unmodified lines | ||
| 212 | 212 | MpegEncContext * const s = &h->s; |
| 213 | 213 | int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); |
| 214 | 214 | int chroma444 = CHROMA444; |
| 215 | + int chroma422 = CHROMA422; | |
| 215 | 216 | |
| 216 | 217 | int mb_xy = h->mb_xy; |
| 217 | 218 | int left_type= h->left_type[LTOP]; |
| @@ -289,6 +290,23 @@ static void av_always_inline h264_filter_mb_fast_internal( H264Context *h, int m · 71 unmodified lines | ||
| 289 | 290 | filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); |
| 290 | 291 | filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); |
| 291 | 292 | } |
| 293 | + }else if(chroma422){ | |
| 294 | + if(left_type){ | |
| 295 | + filter_mb_edgecv(&img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); | |
| 296 | + filter_mb_edgecv(&img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); | |
| 297 | + } | |
| 298 | + filter_mb_edgecv(&img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 299 | + filter_mb_edgecv(&img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 300 | + if(top_type){ | |
| 301 | + filter_mb_edgech(&img_cb[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); | |
| 302 | + filter_mb_edgech(&img_cr[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1); | |
| 303 | + } | |
| 304 | + filter_mb_edgech(&img_cb[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 305 | + filter_mb_edgech(&img_cr[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 306 | + filter_mb_edgech(&img_cb[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 307 | + filter_mb_edgech(&img_cr[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 308 | + filter_mb_edgech(&img_cb[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 309 | + filter_mb_edgech(&img_cr[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0); | |
| 292 | 310 | }else{ |
| 293 | 311 | if(left_type){ |
| 294 | 312 | filter_mb_edgecv( &img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); |
| @@ -411,10 +429,12 @@ static int check_mv(H264Context *h, long b_idx, long bn_idx, int mvy_limit){ · 116 unmodified lines | ||
| 411 | 429 | return v; |
| 412 | 430 | } |
| 413 | 431 | |
| 414 | −static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int a, int b, int chroma, int chroma444, int dir) { | |
| 432 | +static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int a, int b, int chroma, int dir) { | |
| 415 | 433 | MpegEncContext * const s = &h->s; |
| 416 | 434 | int edge; |
| 417 | 435 | int chroma_qp_avg[2]; |
| 436 | + int chroma444 = CHROMA444; | |
| 437 | + int chroma422 = CHROMA422; | |
| 418 | 438 | const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; |
| 419 | 439 | const int mbm_type = dir == 0 ? h->left_type[LTOP] : h->top_type; |
| 420 | 440 | |
| @@ -564,8 +584,9 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u · 143 unmodified lines | ||
| 564 | 584 | for( edge = 1; edge < edges; edge++ ) { |
| 565 | 585 | DECLARE_ALIGNED(8, int16_t, bS)[4]; |
| 566 | 586 | int qp; |
| 587 | + const int deblock_edge = !IS_8x8DCT(mb_type & (edge<<24)); // (edge&1) && IS_8x8DCT(mb_type) | |
| 567 | 588 | |
| 568 | − if( IS_8x8DCT(mb_type & (edge<<24)) ) // (edge&1) && IS_8x8DCT(mb_type) | |
| 589 | + if (!deblock_edge && (!chroma422 || dir == 0)) | |
| 569 | 590 | continue; |
| 570 | 591 | |
| 571 | 592 | if( IS_INTRA(mb_type)) { |
| @@ -627,14 +648,23 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u · 55 unmodified lines | ||
| 627 | 648 | } |
| 628 | 649 | } |
| 629 | 650 | } else { |
| 630 | − filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0 ); | |
| 631 | − if (chroma) { | |
| 632 | − if (chroma444) { | |
| 633 | − filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); | |
| 634 | − filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); | |
| 635 | − } else if( (edge&1) == 0 ) { | |
| 636 | − filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); | |
| 637 | − filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); | |
| 651 | + if (chroma422) { | |
| 652 | + if (deblock_edge) | |
| 653 | + filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0); | |
| 654 | + if (chroma) { | |
| 655 | + filter_mb_edgech(&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); | |
| 656 | + filter_mb_edgech(&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); | |
| 657 | + } | |
| 658 | + } else { | |
| 659 | + filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0); | |
| 660 | + if (chroma) { | |
| 661 | + if (chroma444) { | |
| 662 | + filter_mb_edgeh (&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); | |
| 663 | + filter_mb_edgeh (&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); | |
| 664 | + } else if ((edge&1) == 0) { | |
| 665 | + filter_mb_edgech(&img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); | |
| 666 | + filter_mb_edgech(&img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); | |
| 667 | + } | |
| 638 | 668 | } |
| 639 | 669 | } |
| 640 | 670 | } |
| @@ -726,6 +756,11 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint · 85 unmodified lines | ||
| 726 | 756 | filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 ); |
| 727 | 757 | filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 ); |
| 728 | 758 | filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 ); |
| 759 | + } else if (CHROMA422) { | |
| 760 | + filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1); | |
| 761 | + filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1); | |
| 762 | + filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1); | |
| 763 | + filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1); | |
| 729 | 764 | }else{ |
| 730 | 765 | filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 ); |
| 731 | 766 | filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 ); |
| @@ -754,9 +789,9 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint · 22 unmodified lines | ||
| 754 | 789 | |
| 755 | 790 | #if CONFIG_SMALL |
| 756 | 791 | for( dir = 0; dir < 2; dir++ ) |
| 757 | − filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, CHROMA444, dir); | |
| 792 | + filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, dir); | |
| 758 | 793 | #else |
| 759 | − filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, CHROMA444, 0); | |
| 760 | − filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, CHROMA444, 1); | |
| 794 | + filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0); | |
| 795 | + filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1); | |
| 761 | 796 | #endif |
| 762 | 797 | } |
| @@ -510,7 +510,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 509 unmodified lines | ||
| 510 | 510 | if(top_type){ |
| 511 | 511 | nnz = h->non_zero_count[top_xy]; |
| 512 | 512 | AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); |
| 513 | − if(CHROMA444){ | |
| 513 | + if(!s->chroma_y_shift){ | |
| 514 | 514 | AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); |
| 515 | 515 | AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); |
| 516 | 516 | }else{ |
| @@ -534,6 +534,11 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 17 unmodified lines | ||
| 534 | 534 | nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4]; |
| 535 | 535 | nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4]; |
| 536 | 536 | nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]+8*4]; |
| 537 | + }else if(CHROMA422) { | |
| 538 | + nnz_cache[3+8* 6 + 2*8*i]= nnz[left_block[8+0+2*i]-2+4*4]; | |
| 539 | + nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]-2+4*4]; | |
| 540 | + nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]-2+8*4]; | |
| 541 | + nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]-2+8*4]; | |
| 537 | 542 | }else{ |
| 538 | 543 | nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]]; |
| 539 | 544 | nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]]; |
| @@ -396,7 +396,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ · 395 unmodified lines | ||
| 396 | 396 | #endif |
| 397 | 397 | sps->crop= get_bits1(&s->gb); |
| 398 | 398 | if(sps->crop){ |
| 399 | − int crop_limit = sps->chroma_format_idc == 3 ? 16 : 8; | |
| 399 | + int crop_vertical_limit = sps->chroma_format_idc & 2 ? 16 : 8; | |
| 400 | + int crop_horizontal_limit = sps->chroma_format_idc == 3 ? 16 : 8; | |
| 400 | 401 | sps->crop_left = get_ue_golomb(&s->gb); |
| 401 | 402 | sps->crop_right = get_ue_golomb(&s->gb); |
| 402 | 403 | sps->crop_top = get_ue_golomb(&s->gb); |
| @@ -404,7 +405,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ · 1 unmodified line | ||
| 404 | 405 | if(sps->crop_left || sps->crop_top){ |
| 405 | 406 | av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n"); |
| 406 | 407 | } |
| 407 | − if(sps->crop_right >= crop_limit || sps->crop_bottom >= crop_limit){ | |
| 408 | + if(sps->crop_right >= crop_horizontal_limit || sps->crop_bottom >= crop_vertical_limit){ | |
| 408 | 409 | av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, this could look slightly wrong ...\n"); |
| 409 | 410 | } |
| 410 | 411 | }else{ |
| @@ -80,7 +80,14 @@ static const uint8_t luma_dc_field_scan[16]={ · 79 unmodified lines | ||
| 80 | 80 | |
| 81 | 81 | static const uint8_t chroma_dc_scan[4]={ |
| 82 | 82 | (0+0*2)*16, (1+0*2)*16, |
| 83 | − (0+1*2)*16, (1+1*2)*16, //FIXME | |
| 83 | + (0+1*2)*16, (1+1*2)*16, | |
| 84 | +}; | |
| 85 | + | |
| 86 | +static const uint8_t chroma422_dc_scan[8]={ | |
| 87 | + (0+0*2)*16, (0+1*2)*16, | |
| 88 | + (1+0*2)*16, (0+2*2)*16, | |
| 89 | + (0+3*2)*16, (1+1*2)*16, | |
| 90 | + (1+2*2)*16, (1+3*2)*16, | |
| 84 | 91 | }; |
| 85 | 92 | |
| 86 | 93 | // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)] |
| @@ -41,7 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #include "h264dsp_template.c" |
| 42 | 42 | #undef BIT_DEPTH |
| 43 | 43 | |
| 44 | −void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) | |
| 44 | +void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) | |
| 45 | 45 | { |
| 46 | 46 | #undef FUNC |
| 47 | 47 | #define FUNC(a, depth) a ## _ ## depth ## _c |
| @@ -53,10 +53,16 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) · 5 unmodified lines | ||
| 53 | 53 | c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\ |
| 54 | 54 | c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\ |
| 55 | 55 | c->h264_idct8_add4 = FUNC(ff_h264_idct8_add4, depth);\ |
| 56 | − c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\ | |
| 56 | + if (chroma_format_idc == 1)\ | |
| 57 | + c->h264_idct_add8 = FUNC(ff_h264_idct_add8, depth);\ | |
| 58 | + else\ | |
| 59 | + c->h264_idct_add8 = FUNC(ff_h264_idct_add8_422, depth);\ | |
| 57 | 60 | c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\ |
| 58 | 61 | 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);\ | |
| 62 | + if (chroma_format_idc == 1)\ | |
| 63 | + c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma_dc_dequant_idct, depth);\ | |
| 64 | + else\ | |
| 65 | + c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\ | |
| 60 | 66 | \ |
| 61 | 67 | c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16x16, depth);\ |
| 62 | 68 | c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels16x8, depth);\ |
| @@ -86,11 +92,23 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) · 23 unmodified lines | ||
| 86 | 92 | c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\ |
| 87 | 93 | c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\ |
| 88 | 94 | c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\ |
| 89 | − c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\ | |
| 90 | − c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\ | |
| 95 | + if (chroma_format_idc == 1)\ | |
| 96 | + c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\ | |
| 97 | + else\ | |
| 98 | + c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\ | |
| 99 | + if (chroma_format_idc == 1)\ | |
| 100 | + c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\ | |
| 101 | + else\ | |
| 102 | + c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\ | |
| 91 | 103 | 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);\ | |
| 104 | + if (chroma_format_idc == 1)\ | |
| 105 | + c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\ | |
| 106 | + else\ | |
| 107 | + c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\ | |
| 108 | + if (chroma_format_idc == 1)\ | |
| 109 | + c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\ | |
| 110 | + else\ | |
| 111 | + c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\ | |
| 94 | 112 | c->h264_loop_filter_strength= NULL; |
| 95 | 113 | |
| 96 | 114 | switch (bit_depth) { |
| @@ -105,7 +123,7 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) · 8 unmodified lines | ||
| 105 | 123 | break; |
| 106 | 124 | } |
| 107 | 125 | |
| 108 | − if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth); | |
| 109 | − if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth); | |
| 110 | − if (HAVE_MMX) ff_h264dsp_init_x86(c, bit_depth); | |
| 126 | + if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc); | |
| 127 | + if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc); | |
| 128 | + if (HAVE_MMX) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc); | |
| 111 | 129 | } |
| @@ -74,9 +74,9 @@ typedef struct H264DSPContext{ · 73 unmodified lines | ||
| 74 | 74 | void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); |
| 75 | 75 | }H264DSPContext; |
| 76 | 76 | |
| 77 | −void ff_h264dsp_init(H264DSPContext *c, const int bit_depth); | |
| 78 | −void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth); | |
| 79 | −void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth); | |
| 80 | −void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth); | |
| 77 | +void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | |
| 78 | +void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | |
| 79 | +void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | |
| 80 | +void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); | |
| 81 | 81 | |
| 82 | 82 | #endif /* AVCODEC_H264DSP_H */ |
| @@ -275,6 +275,14 @@ static void FUNCC(h264_h_loop_filter_chroma_mbaff)(uint8_t *pix, int stride, int · 274 unmodified lines | ||
| 275 | 275 | { |
| 276 | 276 | FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 1, alpha, beta, tc0); |
| 277 | 277 | } |
| 278 | +static void FUNCC(h264_h_loop_filter_chroma422)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
| 279 | +{ | |
| 280 | + FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 4, alpha, beta, tc0); | |
| 281 | +} | |
| 282 | +static void FUNCC(h264_h_loop_filter_chroma422_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0) | |
| 283 | +{ | |
| 284 | + FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 2, alpha, beta, tc0); | |
| 285 | +} | |
| 278 | 286 | |
| 279 | 287 | static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma_intra)(uint8_t *_pix, int xstride, int ystride, int inner_iters, int alpha, int beta) |
| 280 | 288 | { |
| @@ -312,3 +320,11 @@ static void FUNCC(h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix, int strid · 31 unmodified lines | ||
| 312 | 320 | { |
| 313 | 321 | FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 1, alpha, beta); |
| 314 | 322 | } |
| 323 | +static void FUNCC(h264_h_loop_filter_chroma422_intra)(uint8_t *pix, int stride, int alpha, int beta) | |
| 324 | +{ | |
| 325 | + FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 4, alpha, beta); | |
| 326 | +} | |
| 327 | +static void FUNCC(h264_h_loop_filter_chroma422_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta) | |
| 328 | +{ | |
| 329 | + FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta); | |
| 330 | +} | |
| @@ -224,6 +224,29 @@ void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, DCTELEM * · 223 unmodified lines | ||
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | + | |
| 228 | +void FUNCC(ff_h264_idct_add8_422)(uint8_t **dest, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[15*8]){ | |
| 229 | + int i, j; | |
| 230 | + | |
| 231 | + for(j=1; j<3; j++){ | |
| 232 | + for(i=j*16; i<j*16+4; i++){ | |
| 233 | + if(nnzc[ scan8[i] ]) | |
| 234 | + FUNCC(ff_h264_idct_add )(dest[j-1] + block_offset[i], block + i*16*sizeof(pixel), stride); | |
| 235 | + else if(((dctcoef*)block)[i*16]) | |
| 236 | + FUNCC(ff_h264_idct_dc_add)(dest[j-1] + block_offset[i], block + i*16*sizeof(pixel), stride); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + | |
| 240 | + for(j=1; j<3; j++){ | |
| 241 | + for(i=j*16+4; i<j*16+8; i++){ | |
| 242 | + if(nnzc[ scan8[i+4] ]) | |
| 243 | + FUNCC(ff_h264_idct_add )(dest[j-1] + block_offset[i+4], block + i*16*sizeof(pixel), stride); | |
| 244 | + else if(((dctcoef*)block)[i*16]) | |
| 245 | + FUNCC(ff_h264_idct_dc_add)(dest[j-1] + block_offset[i+4], block + i*16*sizeof(pixel), stride); | |
| 246 | + } | |
| 247 | + } | |
| 248 | +} | |
| 249 | + | |
| 227 | 250 | /** |
| 228 | 251 | * IDCT transforms the 16 dc values and dequantizes them. |
| 229 | 252 | * @param qmul quantization parameter |
| @@ -263,6 +286,33 @@ void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *_output, DCTELEM *_input, int · 33 unmodified lines | ||
| 263 | 286 | #undef stride |
| 264 | 287 | } |
| 265 | 288 | |
| 289 | +void FUNCC(ff_h264_chroma422_dc_dequant_idct)(DCTELEM *_block, int qmul){ | |
| 290 | + const int stride= 16*2; | |
| 291 | + const int xStride= 16; | |
| 292 | + int i; | |
| 293 | + int temp[8]; | |
| 294 | + static const uint8_t x_offset[2]={0, 16}; | |
| 295 | + dctcoef *block = (dctcoef*)_block; | |
| 296 | + | |
| 297 | + for(i=0; i<4; i++){ | |
| 298 | + temp[2*i+0] = block[stride*i + xStride*0] + block[stride*i + xStride*1]; | |
| 299 | + temp[2*i+1] = block[stride*i + xStride*0] - block[stride*i + xStride*1]; | |
| 300 | + } | |
| 301 | + | |
| 302 | + for(i=0; i<2; i++){ | |
| 303 | + const int offset= x_offset[i]; | |
| 304 | + const int z0= temp[2*0+i] + temp[2*2+i]; | |
| 305 | + const int z1= temp[2*0+i] - temp[2*2+i]; | |
| 306 | + const int z2= temp[2*1+i] - temp[2*3+i]; | |
| 307 | + const int z3= temp[2*1+i] + temp[2*3+i]; | |
| 308 | + | |
| 309 | + block[stride*0+offset]= ((z0 + z3)*qmul + 128) >> 8; | |
| 310 | + block[stride*1+offset]= ((z1 + z2)*qmul + 128) >> 8; | |
| 311 | + block[stride*2+offset]= ((z1 - z2)*qmul + 128) >> 8; | |
| 312 | + block[stride*3+offset]= ((z0 - z3)*qmul + 128) >> 8; | |
| 313 | + } | |
| 314 | +} | |
| 315 | + | |
| 266 | 316 | void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *_block, int qmul){ |
| 267 | 317 | const int stride= 16*2; |
| 268 | 318 | const int xStride= 16; |
| @@ -361,7 +361,7 @@ static void pred8x8_tm_vp8_c(uint8_t *src, int stride){ · 360 unmodified lines | ||
| 361 | 361 | /** |
| 362 | 362 | * Set the intra prediction function pointers. |
| 363 | 363 | */ |
| 364 | −void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ | |
| 364 | +void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc){ | |
| 365 | 365 | // MpegEncContext * const s = &h->s; |
| 366 | 366 | |
| 367 | 367 | #undef FUNC |
| @@ -434,20 +434,39 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 66 unmodified lines | ||
| 434 | 434 | h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\ |
| 435 | 435 | h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\ |
| 436 | 436 | \ |
| 437 | − h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\ | |
| 438 | − h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\ | |
| 437 | + if (chroma_format_idc == 1) {\ | |
| 438 | + h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\ | |
| 439 | + h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\ | |
| 440 | + } else {\ | |
| 441 | + h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x16_vertical , depth);\ | |
| 442 | + h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\ | |
| 443 | + }\ | |
| 439 | 444 | if (codec_id != CODEC_ID_VP8) {\ |
| 440 | − h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\ | |
| 445 | + if (chroma_format_idc == 1) {\ | |
| 446 | + h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\ | |
| 447 | + } else {\ | |
| 448 | + h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane , depth);\ | |
| 449 | + }\ | |
| 441 | 450 | } else\ |
| 442 | 451 | h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\ |
| 443 | 452 | if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\ |
| 444 | − h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\ | |
| 445 | − h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\ | |
| 446 | − h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\ | |
| 447 | − h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ | |
| 448 | − h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ | |
| 449 | − h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\ | |
| 450 | − h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\ | |
| 453 | + if (chroma_format_idc == 1) {\ | |
| 454 | + h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\ | |
| 455 | + h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\ | |
| 456 | + h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\ | |
| 457 | + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ | |
| 458 | + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ | |
| 459 | + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\ | |
| 460 | + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\ | |
| 461 | + } else {\ | |
| 462 | + h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x16_dc , depth);\ | |
| 463 | + h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x16_left_dc , depth);\ | |
| 464 | + h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x16_top_dc , depth);\ | |
| 465 | + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ | |
| 466 | + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ | |
| 467 | + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\ | |
| 468 | + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\ | |
| 469 | + }\ | |
| 451 | 470 | }else{\ |
| 452 | 471 | h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\ |
| 453 | 472 | h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\ |
| @@ -457,7 +476,11 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 3 unmodified lines | ||
| 457 | 476 | h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\ |
| 458 | 477 | }\ |
| 459 | 478 | }\ |
| 460 | − h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\ | |
| 479 | + if (chroma_format_idc == 1) {\ | |
| 480 | + h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\ | |
| 481 | + } else {\ | |
| 482 | + h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\ | |
| 483 | + }\ | |
| 461 | 484 | \ |
| 462 | 485 | h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\ |
| 463 | 486 | h->pred16x16[VERT_PRED8x8 ]= FUNCC(pred16x16_vertical , depth);\ |
| @@ -504,6 +527,6 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 40 unmodified lines | ||
| 504 | 527 | break; |
| 505 | 528 | } |
| 506 | 529 | |
| 507 | − if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth); | |
| 508 | − if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id, bit_depth); | |
| 530 | + if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc); | |
| 531 | + if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc); | |
| 509 | 532 | } |
| @@ -101,8 +101,8 @@ typedef struct H264PredContext{ · 100 unmodified lines | ||
| 101 | 101 | void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); |
| 102 | 102 | }H264PredContext; |
| 103 | 103 | |
| 104 | −void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth); | |
| 105 | −void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth); | |
| 106 | −void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth); | |
| 104 | +void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | |
| 105 | +void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | |
| 106 | +void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | |
| 107 | 107 | |
| 108 | 108 | #endif /* AVCODEC_H264PRED_H */ |
| @@ -454,6 +454,19 @@ static void FUNCC(pred8x8_vertical)(uint8_t *_src, int _stride){ · 453 unmodified lines | ||
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | +static void FUNCC(pred8x16_vertical)(uint8_t *_src, int _stride){ | |
| 458 | + int i; | |
| 459 | + pixel *src = (pixel*)_src; | |
| 460 | + int stride = _stride>>(sizeof(pixel)-1); | |
| 461 | + const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0); | |
| 462 | + const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1); | |
| 463 | + | |
| 464 | + for(i=0; i<16; i++){ | |
| 465 | + AV_WN4PA(((pixel4*)(src+i*stride))+0, a); | |
| 466 | + AV_WN4PA(((pixel4*)(src+i*stride))+1, b); | |
| 467 | + } | |
| 468 | +} | |
| 469 | + | |
| 457 | 470 | static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){ |
| 458 | 471 | int i; |
| 459 | 472 | pixel *src = (pixel*)_src; |
| @@ -466,6 +479,17 @@ static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){ · 6 unmodified lines | ||
| 466 | 479 | } |
| 467 | 480 | } |
| 468 | 481 | |
| 482 | +static void FUNCC(pred8x16_horizontal)(uint8_t *_src, int stride){ | |
| 483 | + int i; | |
| 484 | + pixel *src = (pixel*)_src; | |
| 485 | + stride >>= sizeof(pixel)-1; | |
| 486 | + for(i=0; i<16; i++){ | |
| 487 | + const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]); | |
| 488 | + AV_WN4PA(((pixel4*)(src+i*stride))+0, a); | |
| 489 | + AV_WN4PA(((pixel4*)(src+i*stride))+1, a); | |
| 490 | + } | |
| 491 | +} | |
| 492 | + | |
| 469 | 493 | #define PRED8x8_X(n, v)\ |
| 470 | 494 | static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\ |
| 471 | 495 | int i;\ |
| @@ -482,6 +506,11 @@ PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1); · 10 unmodified lines | ||
| 482 | 506 | PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0); |
| 483 | 507 | PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1); |
| 484 | 508 | |
| 509 | +static void FUNCC(pred8x16_128_dc)(uint8_t *_src, int stride){ | |
| 510 | + FUNCC(pred8x8_128_dc)(_src, stride); | |
| 511 | + FUNCC(pred8x8_128_dc)(_src+8*stride, stride); | |
| 512 | +} | |
| 513 | + | |
| 485 | 514 | static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){ |
| 486 | 515 | int i; |
| 487 | 516 | int dc0, dc2; |
| @@ -507,6 +536,11 @@ static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){ · 19 unmodified lines | ||
| 507 | 536 | } |
| 508 | 537 | } |
| 509 | 538 | |
| 539 | +static void FUNCC(pred8x16_left_dc)(uint8_t *_src, int stride){ | |
| 540 | + FUNCC(pred8x8_left_dc)(_src, stride); | |
| 541 | + FUNCC(pred8x8_left_dc)(_src+8*stride, stride); | |
| 542 | +} | |
| 543 | + | |
| 510 | 544 | static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){ |
| 511 | 545 | int i; |
| 512 | 546 | int dc0, dc1; |
| @@ -532,6 +566,27 @@ static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){ · 19 unmodified lines | ||
| 532 | 566 | } |
| 533 | 567 | } |
| 534 | 568 | |
| 569 | +static void FUNCC(pred8x16_top_dc)(uint8_t *_src, int stride){ | |
| 570 | + int i; | |
| 571 | + int dc0, dc1; | |
| 572 | + pixel4 dc0splat, dc1splat; | |
| 573 | + pixel *src = (pixel*)_src; | |
| 574 | + stride >>= sizeof(pixel)-1; | |
| 575 | + | |
| 576 | + dc0=dc1=0; | |
| 577 | + for(i=0;i<4; i++){ | |
| 578 | + dc0+= src[i-stride]; | |
| 579 | + dc1+= src[4+i-stride]; | |
| 580 | + } | |
| 581 | + dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2); | |
| 582 | + dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2); | |
| 583 | + | |
| 584 | + for(i=0; i<16; i++){ | |
| 585 | + AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat); | |
| 586 | + AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat); | |
| 587 | + } | |
| 588 | +} | |
| 589 | + | |
| 535 | 590 | static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){ |
| 536 | 591 | int i; |
| 537 | 592 | int dc0, dc1, dc2; |
| @@ -560,6 +615,48 @@ static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){ · 22 unmodified lines | ||
| 560 | 615 | } |
| 561 | 616 | } |
| 562 | 617 | |
| 618 | +static void FUNCC(pred8x16_dc)(uint8_t *_src, int stride){ | |
| 619 | + int i; | |
| 620 | + int dc0, dc1, dc2, dc3, dc4; | |
| 621 | + pixel4 dc0splat, dc1splat, dc2splat, dc3splat, dc4splat, dc5splat, dc6splat, dc7splat; | |
| 622 | + pixel *src = (pixel*)_src; | |
| 623 | + stride >>= sizeof(pixel)-1; | |
| 624 | + | |
| 625 | + dc0=dc1=dc2=dc3=dc4=0; | |
| 626 | + for(i=0;i<4; i++){ | |
| 627 | + dc0+= src[-1+i*stride] + src[i-stride]; | |
| 628 | + dc1+= src[4+i-stride]; | |
| 629 | + dc2+= src[-1+(i+4)*stride]; | |
| 630 | + dc3+= src[-1+(i+8)*stride]; | |
| 631 | + dc4+= src[-1+(i+12)*stride]; | |
| 632 | + } | |
| 633 | + dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3); | |
| 634 | + dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2); | |
| 635 | + dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2); | |
| 636 | + dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3); | |
| 637 | + dc4splat = PIXEL_SPLAT_X4((dc3 + 2)>>2); | |
| 638 | + dc5splat = PIXEL_SPLAT_X4((dc1 + dc3 + 4)>>3); | |
| 639 | + dc6splat = PIXEL_SPLAT_X4((dc4 + 2)>>2); | |
| 640 | + dc7splat = PIXEL_SPLAT_X4((dc1 + dc4 + 4)>>3); | |
| 641 | + | |
| 642 | + for(i=0; i<4; i++){ | |
| 643 | + AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat); | |
| 644 | + AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat); | |
| 645 | + } | |
| 646 | + for(i=4; i<8; i++){ | |
| 647 | + AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat); | |
| 648 | + AV_WN4PA(((pixel4*)(src+i*stride))+1, dc3splat); | |
| 649 | + } | |
| 650 | + for(i=8; i<12; i++){ | |
| 651 | + AV_WN4PA(((pixel4*)(src+i*stride))+0, dc4splat); | |
| 652 | + AV_WN4PA(((pixel4*)(src+i*stride))+1, dc5splat); | |
| 653 | + } | |
| 654 | + for(i=12; i<16; i++){ | |
| 655 | + AV_WN4PA(((pixel4*)(src+i*stride))+0, dc6splat); | |
| 656 | + AV_WN4PA(((pixel4*)(src+i*stride))+1, dc7splat); | |
| 657 | + } | |
| 658 | +} | |
| 659 | + | |
| 563 | 660 | //the following 4 function should not be optimized! |
| 564 | 661 | static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, int stride){ |
| 565 | 662 | FUNCC(pred8x8_top_dc)(src, stride); |
| @@ -618,6 +715,47 @@ static void FUNCC(pred8x8_plane)(uint8_t *_src, int _stride){ · 52 unmodified lines | ||
| 618 | 715 | } |
| 619 | 716 | } |
| 620 | 717 | |
| 718 | +static void FUNCC(pred8x16_plane)(uint8_t *_src, int _stride){ | |
| 719 | + int j, k; | |
| 720 | + int a; | |
| 721 | + INIT_CLIP | |
| 722 | + pixel *src = (pixel*)_src; | |
| 723 | + int stride = _stride>>(sizeof(pixel)-1); | |
| 724 | + const pixel * const src0 = src +3-stride; | |
| 725 | + const pixel * src1 = src +8*stride-1; | |
| 726 | + const pixel * src2 = src1-2*stride; // == src+6*stride-1; | |
| 727 | + int H = src0[1] - src0[-1]; | |
| 728 | + int V = src1[0] - src2[ 0]; | |
| 729 | + | |
| 730 | + for (k = 2; k <= 4; ++k) { | |
| 731 | + src1 += stride; src2 -= stride; | |
| 732 | + H += k*(src0[k] - src0[-k]); | |
| 733 | + V += k*(src1[0] - src2[ 0]); | |
| 734 | + } | |
| 735 | + for (; k <= 8; ++k) { | |
| 736 | + src1 += stride; src2 -= stride; | |
| 737 | + V += k*(src1[0] - src2[0]); | |
| 738 | + } | |
| 739 | + | |
| 740 | + H = (17*H+16) >> 5; | |
| 741 | + V = (5*V+32) >> 6; | |
| 742 | + | |
| 743 | + a = 16*(src1[0] + src2[8] + 1) - 7*V - 3*H; | |
| 744 | + for(j=16; j>0; --j) { | |
| 745 | + int b = a; | |
| 746 | + a += V; | |
| 747 | + src[0] = CLIP((b ) >> 5); | |
| 748 | + src[1] = CLIP((b+ H) >> 5); | |
| 749 | + src[2] = CLIP((b+2*H) >> 5); | |
| 750 | + src[3] = CLIP((b+3*H) >> 5); | |
| 751 | + src[4] = CLIP((b+4*H) >> 5); | |
| 752 | + src[5] = CLIP((b+5*H) >> 5); | |
| 753 | + src[6] = CLIP((b+6*H) >> 5); | |
| 754 | + src[7] = CLIP((b+7*H) >> 5); | |
| 755 | + src += stride; | |
| 756 | + } | |
| 757 | +} | |
| 758 | + | |
| 621 | 759 | #define SRC(x,y) src[(x)+(y)*stride] |
| 622 | 760 | #define PL(y) \ |
| 623 | 761 | const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2; |
| @@ -999,12 +999,13 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { · 998 unmodified lines | ||
| 999 | 999 | } |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | −void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth) | |
| 1002 | +void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) | |
| 1003 | 1003 | { |
| 1004 | 1004 | if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { |
| 1005 | 1005 | if (bit_depth == 8) { |
| 1006 | 1006 | c->h264_idct_add = ff_h264_idct_add_altivec; |
| 1007 | − c->h264_idct_add8 = ff_h264_idct_add8_altivec; | |
| 1007 | + if (chroma_format_idc == 1) | |
| 1008 | + c->h264_idct_add8 = ff_h264_idct_add8_altivec; | |
| 1008 | 1009 | c->h264_idct_add16 = ff_h264_idct_add16_altivec; |
| 1009 | 1010 | c->h264_idct_add16intra = ff_h264_idct_add16intra_altivec; |
| 1010 | 1011 | c->h264_idct_dc_add= h264_idct_dc_add_altivec; |
| @@ -1343,7 +1343,7 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) · 1342 unmodified lines | ||
| 1343 | 1343 | if (MPV_common_init(s) < 0) |
| 1344 | 1344 | return -1; |
| 1345 | 1345 | |
| 1346 | − ff_h264_pred_init(&r->h, CODEC_ID_RV40, 8); | |
| 1346 | + ff_h264_pred_init(&r->h, CODEC_ID_RV40, 8, 1); | |
| 1347 | 1347 | |
| 1348 | 1348 | #if CONFIG_RV30_DECODER |
| 1349 | 1349 | if (avctx->codec_id == CODEC_ID_RV30) |
| @@ -1769,7 +1769,7 @@ static av_cold int vp8_decode_init(AVCodecContext *avctx) · 1768 unmodified lines | ||
| 1769 | 1769 | avctx->pix_fmt = PIX_FMT_YUV420P; |
| 1770 | 1770 | |
| 1771 | 1771 | dsputil_init(&s->dsp, avctx); |
| 1772 | − ff_h264_pred_init(&s->hpc, CODEC_ID_VP8, 8); | |
| 1772 | + ff_h264_pred_init(&s->hpc, CODEC_ID_VP8, 8, 1); | |
| 1773 | 1773 | ff_vp8dsp_init(&s->vp8dsp); |
| 1774 | 1774 | |
| 1775 | 1775 | return 0; |
| @@ -167,7 +167,7 @@ void ff_pred4x4_tm_vp8_mmxext (uint8_t *src, const uint8_t *topright, int s · 166 unmodified lines | ||
| 167 | 167 | void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride); |
| 168 | 168 | void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride); |
| 169 | 169 | |
| 170 | −void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth) | |
| 170 | +void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) | |
| 171 | 171 | { |
| 172 | 172 | #if HAVE_YASM |
| 173 | 173 | int mm_flags = av_get_cpu_flags(); |
| @@ -176,14 +176,17 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 2 unmodified lines | ||
| 176 | 176 | if (mm_flags & AV_CPU_FLAG_MMX) { |
| 177 | 177 | h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; |
| 178 | 178 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; |
| 179 | − h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx; | |
| 180 | − h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; | |
| 179 | + if (chroma_format_idc == 1) { | |
| 180 | + h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx; | |
| 181 | + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; | |
| 182 | + } | |
| 181 | 183 | if (codec_id == CODEC_ID_VP8) { |
| 182 | 184 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx; |
| 183 | 185 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx; |
| 184 | 186 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; |
| 185 | 187 | } else { |
| 186 | − h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; | |
| 188 | + if (chroma_format_idc == 1) | |
| 189 | + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; | |
| 187 | 190 | if (codec_id == CODEC_ID_SVQ3) { |
| 188 | 191 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; |
| 189 | 192 | } else if (codec_id == CODEC_ID_RV40) { |
| @@ -197,7 +200,8 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 7 unmodified lines | ||
| 197 | 200 | if (mm_flags & AV_CPU_FLAG_MMX2) { |
| 198 | 201 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; |
| 199 | 202 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; |
| 200 | − h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; | |
| 203 | + if (chroma_format_idc == 1) | |
| 204 | + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; | |
| 201 | 205 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; |
| 202 | 206 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; |
| 203 | 207 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; |
| @@ -221,8 +225,10 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 17 unmodified lines | ||
| 221 | 225 | h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; |
| 222 | 226 | } |
| 223 | 227 | if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { |
| 224 | − h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; | |
| 225 | − h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; | |
| 228 | + if (chroma_format_idc == 1) { | |
| 229 | + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; | |
| 230 | + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; | |
| 231 | + } | |
| 226 | 232 | } |
| 227 | 233 | if (codec_id == CODEC_ID_VP8) { |
| 228 | 234 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmxext; |
| @@ -231,7 +237,8 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 2 unmodified lines | ||
| 231 | 237 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; |
| 232 | 238 | h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; |
| 233 | 239 | } else { |
| 234 | − h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; | |
| 240 | + if (chroma_format_idc == 1) | |
| 241 | + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; | |
| 235 | 242 | if (codec_id == CODEC_ID_SVQ3) { |
| 236 | 243 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_mmx2; |
| 237 | 244 | } else if (codec_id == CODEC_ID_RV40) { |
| @@ -257,7 +264,8 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 19 unmodified lines | ||
| 257 | 264 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2; |
| 258 | 265 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2; |
| 259 | 266 | } else { |
| 260 | − h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_plane_sse2; | |
| 267 | + if (chroma_format_idc == 1) | |
| 268 | + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_sse2; | |
| 261 | 269 | if (codec_id == CODEC_ID_SVQ3) { |
| 262 | 270 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; |
| 263 | 271 | } else if (codec_id == CODEC_ID_RV40) { |
| @@ -271,7 +279,8 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 7 unmodified lines | ||
| 271 | 279 | if (mm_flags & AV_CPU_FLAG_SSSE3) { |
| 272 | 280 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; |
| 273 | 281 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; |
| 274 | − h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; | |
| 282 | + if (chroma_format_idc == 1) | |
| 283 | + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; | |
| 275 | 284 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; |
| 276 | 285 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; |
| 277 | 286 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; |
| @@ -286,7 +295,8 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 8 unmodified lines | ||
| 286 | 295 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3; |
| 287 | 296 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; |
| 288 | 297 | } else { |
| 289 | − h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; | |
| 298 | + if (chroma_format_idc == 1) | |
| 299 | + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; | |
| 290 | 300 | if (codec_id == CODEC_ID_SVQ3) { |
| 291 | 301 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; |
| 292 | 302 | } else if (codec_id == CODEC_ID_RV40) { |
| @@ -301,7 +311,8 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 8 unmodified lines | ||
| 301 | 311 | h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; |
| 302 | 312 | h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; |
| 303 | 313 | |
| 304 | − h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext; | |
| 314 | + if (chroma_format_idc == 1) | |
| 315 | + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext; | |
| 305 | 316 | |
| 306 | 317 | h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext; |
| 307 | 318 | |
| @@ -319,11 +330,13 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 11 unmodified lines | ||
| 319 | 330 | h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2; |
| 320 | 331 | h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2; |
| 321 | 332 | |
| 322 | − h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2; | |
| 323 | − h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2; | |
| 324 | − h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2; | |
| 325 | − h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2; | |
| 326 | − h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2; | |
| 333 | + if (chroma_format_idc == 1) { | |
| 334 | + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2; | |
| 335 | + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2; | |
| 336 | + h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2; | |
| 337 | + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2; | |
| 338 | + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2; | |
| 339 | + } | |
| 327 | 340 | |
| 328 | 341 | h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2; |
| 329 | 342 | h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_sse2; |
| @@ -350,7 +350,7 @@ H264_BIWEIGHT_10_SSE( 4, 8, 10) · 349 unmodified lines | ||
| 350 | 350 | H264_BIWEIGHT_10_SSE( 4, 4, 10) |
| 351 | 351 | H264_BIWEIGHT_10_SSE( 4, 2, 10) |
| 352 | 352 | |
| 353 | −void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) | |
| 353 | +void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) | |
| 354 | 354 | { |
| 355 | 355 | int mm_flags = av_get_cpu_flags(); |
| 356 | 356 | |
| @@ -368,7 +368,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 11 unmodified lines | ||
| 368 | 368 | |
| 369 | 369 | c->h264_idct_add16 = ff_h264_idct_add16_8_mmx; |
| 370 | 370 | c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmx; |
| 371 | − c->h264_idct_add8 = ff_h264_idct_add8_8_mmx; | |
| 371 | + if (chroma_format_idc == 1) | |
| 372 | + c->h264_idct_add8 = ff_h264_idct_add8_8_mmx; | |
| 372 | 373 | c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmx; |
| 373 | 374 | c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_mmx; |
| 374 | 375 | |
| @@ -377,13 +378,16 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 2 unmodified lines | ||
| 377 | 378 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmx2; |
| 378 | 379 | c->h264_idct_add16 = ff_h264_idct_add16_8_mmx2; |
| 379 | 380 | c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmx2; |
| 380 | − c->h264_idct_add8 = ff_h264_idct_add8_8_mmx2; | |
| 381 | + if (chroma_format_idc == 1) | |
| 382 | + c->h264_idct_add8 = ff_h264_idct_add8_8_mmx2; | |
| 381 | 383 | c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx2; |
| 382 | 384 | |
| 383 | 385 | c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_8_mmxext; |
| 384 | − c->h264_h_loop_filter_chroma= ff_deblock_h_chroma_8_mmxext; | |
| 385 | 386 | c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_8_mmxext; |
| 386 | − c->h264_h_loop_filter_chroma_intra= ff_deblock_h_chroma_intra_8_mmxext; | |
| 387 | + if (chroma_format_idc == 1) { | |
| 388 | + c->h264_h_loop_filter_chroma= ff_deblock_h_chroma_8_mmxext; | |
| 389 | + c->h264_h_loop_filter_chroma_intra= ff_deblock_h_chroma_intra_8_mmxext; | |
| 390 | + } | |
| 387 | 391 | #if ARCH_X86_32 |
| 388 | 392 | c->h264_v_loop_filter_luma= ff_deblock_v_luma_8_mmxext; |
| 389 | 393 | c->h264_h_loop_filter_luma= ff_deblock_h_luma_8_mmxext; |
| @@ -413,7 +417,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 23 unmodified lines | ||
| 413 | 417 | |
| 414 | 418 | c->h264_idct_add16 = ff_h264_idct_add16_8_sse2; |
| 415 | 419 | c->h264_idct8_add4 = ff_h264_idct8_add4_8_sse2; |
| 416 | − c->h264_idct_add8 = ff_h264_idct_add8_8_sse2; | |
| 420 | + if (chroma_format_idc == 1) | |
| 421 | + c->h264_idct_add8 = ff_h264_idct_add8_8_sse2; | |
| 417 | 422 | c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2; |
| 418 | 423 | c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_sse2; |
| 419 | 424 | |
| @@ -472,7 +477,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 52 unmodified lines | ||
| 472 | 477 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_sse2; |
| 473 | 478 | |
| 474 | 479 | c->h264_idct_add16 = ff_h264_idct_add16_10_sse2; |
| 475 | − c->h264_idct_add8 = ff_h264_idct_add8_10_sse2; | |
| 480 | + if (chroma_format_idc == 1) | |
| 481 | + c->h264_idct_add8 = ff_h264_idct_add8_10_sse2; | |
| 476 | 482 | c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2; |
| 477 | 483 | #if HAVE_ALIGNED_STACK |
| 478 | 484 | c->h264_idct8_add = ff_h264_idct8_add_10_sse2; |
| @@ -532,7 +538,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 53 unmodified lines | ||
| 532 | 538 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_avx; |
| 533 | 539 | |
| 534 | 540 | c->h264_idct_add16 = ff_h264_idct_add16_10_avx; |
| 535 | − c->h264_idct_add8 = ff_h264_idct_add8_10_avx; | |
| 541 | + if (chroma_format_idc == 1) | |
| 542 | + c->h264_idct_add8 = ff_h264_idct_add8_10_avx; | |
| 536 | 543 | c->h264_idct_add16intra= ff_h264_idct_add16intra_10_avx; |
| 537 | 544 | #if HAVE_ALIGNED_STACK |
| 538 | 545 | c->h264_idct8_add = ff_h264_idct8_add_10_avx; |