Unified · Split
| @@ -54,6 +54,7 @@ easier to use. The changes are: · 53 unmodified lines | |||
| 54 | - boxblur filter | 54 | - boxblur filter |
| 55 | - Ut Video decoder | 55 | - Ut Video decoder |
| 56 | - Speex encoding via libspeex | 56 | - Speex encoding via libspeex |
| 57 | - 4:2:2 H.264 decoding support | ||
| 57 | 58 | ||
| 58 | 59 | ||
| 59 | version 0.7: | 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 | DCTELEM *block, int stride, | 92 | DCTELEM *block, int stride, |
| 93 | const uint8_t nnzc[6*8]); | 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 | if (bit_depth == 8) { | 97 | if (bit_depth == 8) { |
| 98 | c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; | 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 | c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; | 122 | c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; |
| 123 | c->h264_idct_add16 = ff_h264_idct_add16_neon; | 123 | c->h264_idct_add16 = ff_h264_idct_add16_neon; |
| 124 | c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; | 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 | c->h264_idct8_add = ff_h264_idct8_add_neon; | 127 | c->h264_idct8_add = ff_h264_idct8_add_neon; |
| 127 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; | 128 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; |
| 128 | c->h264_idct8_add4 = ff_h264_idct8_add4_neon; | 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 | void ff_pred8x8_l00_dc_neon(uint8_t *src, int stride); | 42 | void ff_pred8x8_l00_dc_neon(uint8_t *src, int stride); |
| 43 | void ff_pred8x8_0l0_dc_neon(uint8_t *src, int stride); | 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 | const int high_depth = bit_depth > 8; | 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 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; | 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 | void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | 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 | void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | 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 | void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | 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 | void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\ | 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 | void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(DCTELEM *output, DCTELEM *input, int qmul);\ | 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 | void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(DCTELEM *block, int qmul); | 70 | void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(DCTELEM *block, int qmul); |
| 69 | 71 | ||
| 70 | H264_IDCT( 8) | 72 | H264_IDCT( 8) |
| @@ -942,7 +942,7 @@ static void clone_tables(H264Context *dst, H264Context *src, int i){ · 941 unmodified lines | |||
| 942 | dst->list_counts = src->list_counts; | 942 | dst->list_counts = src->list_counts; |
| 943 | 943 | ||
| 944 | dst->s.obmc_scratchpad = NULL; | 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 | s->height = s->avctx->height; | 970 | s->height = s->avctx->height; |
| 971 | s->codec_id= s->avctx->codec->id; | 971 | s->codec_id= s->avctx->codec->id; |
| 972 | 972 | ||
| 973 | ff_h264dsp_init(&h->h264dsp, 8); | 973 | ff_h264dsp_init(&h->h264dsp, 8, 1); |
| 974 | ff_h264_pred_init(&h->hpc, s->codec_id, 8); | 974 | ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1); |
| 975 | 975 | ||
| 976 | h->dequant_coeff_pps= -1; | 976 | h->dequant_coeff_pps= -1; |
| 977 | s->unrestricted_mv=1; | 977 | s->unrestricted_mv=1; |
| @@ -1432,11 +1432,16 @@ static void decode_postinit(H264Context *h, int setup_finished){ · 454 unmodified lines | |||
| 1432 | ff_thread_finish_setup(s->avctx); | 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 | MpegEncContext * const s = &h->s; | 1439 | MpegEncContext * const s = &h->s; |
| 1437 | uint8_t *top_border; | 1440 | uint8_t *top_border; |
| 1438 | int top_idx = 1; | 1441 | int top_idx = 1; |
| 1439 | const int pixel_shift = h->pixel_shift; | 1442 | const int pixel_shift = h->pixel_shift; |
| 1443 | int chroma444 = CHROMA444; | ||
| 1444 | int chroma422 = CHROMA422; | ||
| 1440 | 1445 | ||
| 1441 | src_y -= linesize; | 1446 | src_y -= linesize; |
| 1442 | src_cb -= uvlinesize; | 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 | AV_COPY128(top_border+16, src_cb + 15*uvlinesize); | 1465 | AV_COPY128(top_border+16, src_cb + 15*uvlinesize); |
| 1461 | AV_COPY128(top_border+32, src_cr + 15*uvlinesize); | 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 | } else { | 1476 | } else { |
| 1464 | if (pixel_shift) { | 1477 | if (pixel_shift) { |
| 1465 | AV_COPY128(top_border+32, src_cb+7*uvlinesize); | 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 | AV_COPY128(top_border+16, src_cb + 16*linesize); | 1508 | AV_COPY128(top_border+16, src_cb + 16*linesize); |
| 1496 | AV_COPY128(top_border+32, src_cr + 16*linesize); | 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 | } else { | 1519 | } else { |
| 1499 | if (pixel_shift) { | 1520 | if (pixel_shift) { |
| 1500 | AV_COPY128(top_border+32, src_cb+8*uvlinesize); | 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 | /* is_h264 should always be true if SVQ3 is disabled. */ | 1794 | /* is_h264 should always be true if SVQ3 is disabled. */ |
| 1774 | const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264; | 1795 | const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264; |
| 1775 | void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); | 1796 | void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); |
| 1797 | const int block_h = 16 >> s->chroma_y_shift; | ||
| 1776 | 1798 | ||
| 1777 | dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; | 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; | 1800 | dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift)*8 + mb_y * s->uvlinesize * block_h; |
| 1779 | dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8; | 1801 | dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift)*8 + mb_y * s->uvlinesize * block_h; |
| 1780 | 1802 | ||
| 1781 | s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4); | 1803 | s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4); |
| 1782 | s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + (64 << pixel_shift), dest_cr - dest_cb, 2); | 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 | block_offset = &h->block_offset[48]; | 1811 | block_offset = &h->block_offset[48]; |
| 1790 | if(mb_y&1){ //FIXME move out of this function? | 1812 | if(mb_y&1){ //FIXME move out of this function? |
| 1791 | dest_y -= s->linesize*15; | 1813 | dest_y -= s->linesize*15; |
| 1792 | dest_cb-= s->uvlinesize*7; | 1814 | dest_cb-= s->uvlinesize * (block_h - 1); |
| 1793 | dest_cr-= s->uvlinesize*7; | 1815 | dest_cr-= s->uvlinesize * (block_h - 1); |
| 1794 | } | 1816 | } |
| 1795 | if(FRAME_MBAFF) { | 1817 | if(FRAME_MBAFF) { |
| 1796 | int list; | 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 | } else { | 1866 | } else { |
| 1845 | for (i = 0; i < 8; i++) { | 1867 | for (i = 0; i < block_h; i++) { |
| 1846 | uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize); | 1868 | uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize); |
| 1847 | for (j = 0; j < 8; j++) | 1869 | for (j = 0; j < 8; j++) |
| 1848 | tmp_cb[j] = get_bits(&gb, bit_depth); | 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 | uint16_t *tmp_cr = (uint16_t*)(dest_cr + i*uvlinesize); | 1873 | uint16_t *tmp_cr = (uint16_t*)(dest_cr + i*uvlinesize); |
| 1852 | for (j = 0; j < 8; j++) | 1874 | for (j = 0; j < 8; j++) |
| 1853 | tmp_cr[j] = get_bits(&gb, bit_depth); | 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 | memset(dest_cr + i*uvlinesize, 128, 8); | 1887 | memset(dest_cr + i*uvlinesize, 128, 8); |
| 1866 | } | 1888 | } |
| 1867 | } else { | 1889 | } else { |
| 1868 | for (i = 0; i < 8; i++) { | 1890 | for (i = 0; i < block_h; i++) { |
| 1869 | memcpy(dest_cb + i*uvlinesize, h->mb + 128 + i*4, 8); | 1891 | memcpy(dest_cb + i*uvlinesize, h->mb + 128 + i*4, 8); |
| 1870 | memcpy(dest_cr + i*uvlinesize, h->mb + 160 + i*4, 8); | 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 | }else{ | 1936 | }else{ |
| 1915 | if(is_h264){ | 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 | if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+0] ]) | 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 | if(h->non_zero_count_cache[ scan8[CHROMA_DC_BLOCK_INDEX+1] ]) | 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 | h->h264dsp.h264_idct_add8(dest, block_offset, | 1950 | h->h264dsp.h264_idct_add8(dest, block_offset, |
| 1921 | h->mb, uvlinesize, | 1951 | h->mb, uvlinesize, |
| 1922 | h->non_zero_count_cache); | 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 | h->b_stride= s->mb_width*4; | 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 | s->width = 16*s->mb_width - (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1); | 2590 | s->width = 16*s->mb_width - (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1); |
| 2559 | if(h->sps.frame_mbs_only_flag) | 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 | else | 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 | if (s->context_initialized | 2596 | if (s->context_initialized |
| 2565 | && ( s->width != s->avctx->width || s->height != s->avctx->height | 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 | switch (h->sps.bit_depth_luma) { | 2634 | switch (h->sps.bit_depth_luma) { |
| 2603 | case 9 : | 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 | break; | 2642 | break; |
| 2606 | case 10 : | 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 | break; | 2650 | break; |
| 2609 | default: | 2651 | default: |
| 2610 | if (CHROMA444){ | 2652 | if (CHROMA444){ |
| 2611 | s->avctx->pix_fmt = s->avctx->color_range == AVCOL_RANGE_JPEG ? PIX_FMT_YUVJ444P : PIX_FMT_YUV444P; | 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 | }else{ | 2656 | }else{ |
| 2613 | s->avctx->pix_fmt = s->avctx->get_format(s->avctx, | 2657 | s->avctx->pix_fmt = s->avctx->get_format(s->avctx, |
| 2614 | s->avctx->codec->pix_fmts ? | 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 | const int end_mb_y= s->mb_y + FRAME_MBAFF; | 3316 | const int end_mb_y= s->mb_y + FRAME_MBAFF; |
| 3273 | const int old_slice_type= h->slice_type; | 3317 | const int old_slice_type= h->slice_type; |
| 3274 | const int pixel_shift = h->pixel_shift; | 3318 | const int pixel_shift = h->pixel_shift; |
| 3319 | const int block_h = 16 >> s->chroma_y_shift; | ||
| 3275 | 3320 | ||
| 3276 | if(h->deblocking_filter) { | 3321 | if(h->deblocking_filter) { |
| 3277 | for(mb_x= start_x; mb_x<end_x; mb_x++){ | 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 | s->mb_x= mb_x; | 3333 | s->mb_x= mb_x; |
| 3289 | s->mb_y= mb_y; | 3334 | s->mb_y= mb_y; |
| 3290 | dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; | 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); | 3336 | dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h; |
| 3292 | dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444); | 3337 | dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h; |
| 3293 | //FIXME simplify above | 3338 | //FIXME simplify above |
| 3294 | 3339 | ||
| 3295 | if (MB_FIELD) { | 3340 | if (MB_FIELD) { |
| @@ -3297,14 +3342,14 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ · 1 unmodified line | |||
| 3297 | uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2; | 3342 | uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2; |
| 3298 | if(mb_y&1){ //FIXME move out of this function? | 3343 | if(mb_y&1){ //FIXME move out of this function? |
| 3299 | dest_y -= s->linesize*15; | 3344 | dest_y -= s->linesize*15; |
| 3300 | dest_cb-= s->uvlinesize*((8 << CHROMA444)-1); | 3345 | dest_cb-= s->uvlinesize * (block_h - 1); |
| 3301 | dest_cr-= s->uvlinesize*((8 << CHROMA444)-1); | 3346 | dest_cr-= s->uvlinesize * (block_h - 1); |
| 3302 | } | 3347 | } |
| 3303 | } else { | 3348 | } else { |
| 3304 | linesize = h->mb_linesize = s->linesize; | 3349 | linesize = h->mb_linesize = s->linesize; |
| 3305 | uvlinesize = h->mb_uvlinesize = s->uvlinesize; | 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 | if(fill_filter_caches(h, mb_type)) | 3353 | if(fill_filter_caches(h, mb_type)) |
| 3309 | continue; | 3354 | continue; |
| 3310 | h->chroma_qp[0] = get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mb_xy]); | 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 | if(avctx->has_b_frames < 2) | 3787 | if(avctx->has_b_frames < 2) |
| 3743 | avctx->has_b_frames= !s->low_delay; | 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 | if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) { | 3792 | if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) { |
| 3747 | avctx->bits_per_raw_sample = h->sps.bit_depth_luma; | 3793 | avctx->bits_per_raw_sample = h->sps.bit_depth_luma; |
| 3794 | h->cur_chroma_format_idc = h->sps.chroma_format_idc; | ||
| 3748 | h->pixel_shift = h->sps.bit_depth_luma > 8; | 3795 | h->pixel_shift = h->sps.bit_depth_luma > 8; |
| 3749 | 3796 | ||
| 3750 | ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma); | 3797 | ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma, h->sps.chroma_format_idc); |
| 3751 | ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma); | 3798 | ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma, h->sps.chroma_format_idc); |
| 3752 | s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16; | 3799 | s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16; |
| 3753 | dsputil_init(&s->dsp, s->avctx); | 3800 | dsputil_init(&s->dsp, s->avctx); |
| 3754 | } else { | 3801 | } else { |
| @@ -39,13 +39,6 @@ · 38 unmodified lines | |||
| 39 | #define interlaced_dct interlaced_dct_is_a_bad_name | 39 | #define interlaced_dct interlaced_dct_is_a_bad_name |
| 40 | #define mb_intra mb_intra_is_not_initialized_see_mb_type | 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 | #define MAX_SPS_COUNT 32 | 42 | #define MAX_SPS_COUNT 32 |
| 50 | #define MAX_PPS_COUNT 256 | 43 | #define MAX_PPS_COUNT 256 |
| 51 | 44 | ||
| @@ -92,6 +85,7 @@ · 40 unmodified lines | |||
| 92 | #define CABAC h->pps.cabac | 85 | #define CABAC h->pps.cabac |
| 93 | #endif | 86 | #endif |
| 94 | 87 | ||
| 88 | #define CHROMA422 (h->sps.chroma_format_idc == 2) | ||
| 95 | #define CHROMA444 (h->sps.chroma_format_idc == 3) | 89 | #define CHROMA444 (h->sps.chroma_format_idc == 3) |
| 96 | 90 | ||
| 97 | #define EXTENDED_SAR 255 | 91 | #define EXTENDED_SAR 255 |
| @@ -582,6 +576,8 @@ typedef struct H264Context{ · 484 unmodified lines | |||
| 582 | // Timestamp stuff | 576 | // Timestamp stuff |
| 583 | int sei_buffering_period_present; ///< Buffering period SEI flag | 577 | int sei_buffering_period_present; ///< Buffering period SEI flag |
| 584 | int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs | 578 | int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs |
| 579 | |||
| 580 | int cur_chroma_format_idc; | ||
| 585 | }H264Context; | 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 | AV_COPY32(&nnz[32], &nnz_cache[4+8*11]); | 805 | AV_COPY32(&nnz[32], &nnz_cache[4+8*11]); |
| 810 | AV_COPY32(&nnz[36], &nnz_cache[4+8*12]); | 806 | AV_COPY32(&nnz[36], &nnz_cache[4+8*12]); |
| 811 | 807 | ||
| 812 | if(CHROMA444){ | 808 | if(!h->s.chroma_y_shift){ |
| 813 | AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]); | 809 | AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]); |
| 814 | AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]); | 810 | AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]); |
| 815 | AV_COPY32(&nnz[40], &nnz_cache[4+8*13]); | 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 | 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8 | 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 | static const int significant_coeff_flag_offset[2][14] = { | 1574 | static const int significant_coeff_flag_offset[2][14] = { |
| 1570 | { 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 }, | 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 | { 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 } | 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 | 9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9, | 1592 | 9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9, |
| 1588 | 9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 } | 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 | /* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0). | 1596 | /* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0). |
| 1591 | * 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter). | 1597 | * 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter). |
| 1592 | * map node ctx => cabac ctx for level=1 */ | 1598 | * map node ctx => cabac ctx for level=1 */ |
| 1593 | static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 }; | 1599 | static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 }; |
| 1594 | /* map node ctx => cabac ctx for level>1 */ | 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 | static const uint8_t coeff_abs_level_transition[2][8] = { | 1605 | static const uint8_t coeff_abs_level_transition[2][8] = { |
| 1597 | /* update node ctx after decoding a level=1 */ | 1606 | /* update node ctx after decoding a level=1 */ |
| 1598 | { 1, 2, 3, 3, 4, 5, 6, 7 }, | 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 | coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, | 1660 | coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, |
| 1652 | last_coeff_ctx_base, sig_off); | 1661 | last_coeff_ctx_base, sig_off); |
| 1653 | } else { | 1662 | } else { |
| 1654 | coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, | 1663 | if (is_dc && chroma422) { // dc 422 |
| 1655 | last_coeff_ctx_base-significant_coeff_ctx_base); | 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 | #else | 1669 | #else |
| 1657 | DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] ); | 1670 | DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] ); |
| 1658 | } else { | 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 | #endif | 1677 | #endif |
| 1661 | } | 1678 | } |
| 1662 | assert(coeff_count > 0); | 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 | } else { \ | 1709 | } else { \ |
| 1693 | int coeff_abs = 2; \ | 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 | node_ctx = coeff_abs_level_transition[1][node_ctx]; \ | 1712 | node_ctx = coeff_abs_level_transition[1][node_ctx]; \ |
| 1696 | \ | 1713 | \ |
| 1697 | while( coeff_abs < 15 && get_cabac( CC, ctx ) ) { \ | 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 | static void decode_cabac_residual_dc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) { | 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 | 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 ) { | 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 | /* cat: 0-> DC 16x16 n = 0 | 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 | decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff ); | 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 | 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 ) { | 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 | /* read coded block flag */ | 1802 | /* read coded block flag */ |
| 1766 | if( (cat != 5 || CHROMA444) && get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 0 ) ] ) == 0 ) { | 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 | if(CHROMA444){ | 2350 | if(CHROMA444){ |
| 2314 | decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1); | 2351 | decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1); |
| 2315 | decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2); | 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 | if( cbp&0x30 ){ | 2383 | if( cbp&0x30 ){ |
| 2318 | int c; | 2384 | int c; |
| 2319 | for( c = 0; c < 2; c++ ) { | 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 | 2, 3, 2, 0, | 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 | static const uint8_t coeff_token_len[4][4*17]={ | 89 | static const uint8_t coeff_token_len[4][4*17]={ |
| 66 | { | 90 | { |
| 67 | 1, 0, 0, 0, | 91 | 1, 0, 0, 0, |
| @@ -172,6 +196,26 @@ static const uint8_t chroma_dc_total_zeros_bits[3][4]= { · 104 unmodified lines | |||
| 172 | { 1, 0, 0, 0,}, | 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 | static const uint8_t run_len[7][16]={ | 219 | static const uint8_t run_len[7][16]={ |
| 176 | {1,1}, | 220 | {1,1}, |
| 177 | {1,2,2}, | 221 | {1,2,2}, |
| @@ -200,6 +244,10 @@ static VLC chroma_dc_coeff_token_vlc; · 22 unmodified lines | |||
| 200 | static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2]; | 244 | static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2]; |
| 201 | static const int chroma_dc_coeff_token_vlc_table_size = 256; | 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 | static VLC total_zeros_vlc[15]; | 251 | static VLC total_zeros_vlc[15]; |
| 204 | static VLC_TYPE total_zeros_vlc_tables[15][512][2]; | 252 | static VLC_TYPE total_zeros_vlc_tables[15][512][2]; |
| 205 | static const int total_zeros_vlc_tables_size = 512; | 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 | static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2]; | 256 | static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2]; |
| 209 | static const int chroma_dc_total_zeros_vlc_tables_size = 8; | 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 | static VLC run_vlc[6]; | 263 | static VLC run_vlc[6]; |
| 212 | static VLC_TYPE run_vlc_tables[6][8][2]; | 264 | static VLC_TYPE run_vlc_tables[6][8][2]; |
| 213 | static const int run_vlc_tables_size = 8; | 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 | #define LEVEL_TAB_BITS 8 | 271 | #define LEVEL_TAB_BITS 8 |
| 220 | static int8_t cavlc_level_tab[7][1<<LEVEL_TAB_BITS][2]; | 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 | * gets the predicted number of non-zero coefficients. | 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 | &chroma_dc_coeff_token_bits[0], 1, 1, | 338 | &chroma_dc_coeff_token_bits[0], 1, 1, |
| 279 | INIT_VLC_USE_NEW_STATIC); | 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 | offset = 0; | 348 | offset = 0; |
| 282 | for(i=0; i<4; i++){ | 349 | for(i=0; i<4; i++){ |
| 283 | coeff_token_vlc[i].table = coeff_token_vlc_tables+offset; | 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 | &chroma_dc_total_zeros_bits[i][0], 1, 1, | 371 | &chroma_dc_total_zeros_bits[i][0], 1, 1, |
| 305 | INIT_VLC_USE_NEW_STATIC); | 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 | for(i=0; i<15; i++){ | 385 | for(i=0; i<15; i++){ |
| 308 | total_zeros_vlc[i].table = total_zeros_vlc_tables[i]; | 386 | total_zeros_vlc[i].table = total_zeros_vlc_tables[i]; |
| 309 | total_zeros_vlc[i].table_allocated = total_zeros_vlc_tables_size; | 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 | //FIXME put trailing_onex into the context | 451 | //FIXME put trailing_onex into the context |
| 374 | 452 | ||
| 375 | if(max_coeff <= 8){ | 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 | total_coeff= coeff_token>>2; | 458 | total_coeff= coeff_token>>2; |
| 378 | }else{ | 459 | }else{ |
| 379 | if(n >= LUMA_DC_BLOCK_INDEX){ | 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 | if(total_coeff == max_coeff) | 564 | if(total_coeff == max_coeff) |
| 484 | zeros_left=0; | 565 | zeros_left=0; |
| 485 | else{ | 566 | else{ |
| 486 | /* FIXME: we don't actually support 4:2:2 yet. */ | 567 | if (max_coeff <= 8) { |
| 487 | if(max_coeff <= 8) | 568 | if (max_coeff == 4) |
| 488 | zeros_left= get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[ total_coeff ].table, CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1); | 569 | zeros_left = get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[total_coeff].table, |
| 489 | else | 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 | zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1); | 575 | zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1); |
| 576 | } | ||
| 491 | } | 577 | } |
| 492 | 578 | ||
| 493 | #define STORE_BLOCK(type) \ | 579 | #define STORE_BLOCK(type) \ |
| @@ -994,7 +1080,7 @@ decode_intra_mb: · 500 unmodified lines | |||
| 994 | s->current_picture.f.mb_type[mb_xy] = mb_type; | 1080 | s->current_picture.f.mb_type[mb_xy] = mb_type; |
| 995 | 1081 | ||
| 996 | if(cbp || IS_INTRA16x16(mb_type)){ | 1082 | if(cbp || IS_INTRA16x16(mb_type)){ |
| 997 | int i4x4, chroma_idx; | 1083 | int i4x4, i8x8, chroma_idx; |
| 998 | int dquant; | 1084 | int dquant; |
| 999 | int ret; | 1085 | int ret; |
| 1000 | GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr; | 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 | if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ){ | 1122 | if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ){ |
| 1037 | return -1; | 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 | if(cbp&0x30){ | 1153 | if(cbp&0x30){ |
| 1041 | for(chroma_idx=0; chroma_idx<2; chroma_idx++) | 1154 | for(chroma_idx=0; chroma_idx<2; chroma_idx++) |
| 1042 | 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){ | 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 | MpegEncContext * const s = &h->s; | 212 | MpegEncContext * const s = &h->s; |
| 213 | int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); | 213 | int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); |
| 214 | int chroma444 = CHROMA444; | 214 | int chroma444 = CHROMA444; |
| 215 | int chroma422 = CHROMA422; | ||
| 215 | 216 | ||
| 216 | int mb_xy = h->mb_xy; | 217 | int mb_xy = h->mb_xy; |
| 217 | int left_type= h->left_type[LTOP]; | 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 | filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); | 290 | filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); |
| 290 | filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0); | 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 | }else{ | 310 | }else{ |
| 293 | if(left_type){ | 311 | if(left_type){ |
| 294 | filter_mb_edgecv( &img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1); | 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 | return v; | 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 | MpegEncContext * const s = &h->s; | 433 | MpegEncContext * const s = &h->s; |
| 416 | int edge; | 434 | int edge; |
| 417 | int chroma_qp_avg[2]; | 435 | int chroma_qp_avg[2]; |
| 436 | int chroma444 = CHROMA444; | ||
| 437 | int chroma422 = CHROMA422; | ||
| 418 | const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; | 438 | const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy; |
| 419 | const int mbm_type = dir == 0 ? h->left_type[LTOP] : h->top_type; | 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 | for( edge = 1; edge < edges; edge++ ) { | 584 | for( edge = 1; edge < edges; edge++ ) { |
| 565 | DECLARE_ALIGNED(8, int16_t, bS)[4]; | 585 | DECLARE_ALIGNED(8, int16_t, bS)[4]; |
| 566 | int qp; | 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 | continue; | 590 | continue; |
| 570 | 591 | ||
| 571 | if( IS_INTRA(mb_type)) { | 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 | } else { | 650 | } else { |
| 630 | filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0 ); | 651 | if (chroma422) { |
| 631 | if (chroma) { | 652 | if (deblock_edge) |
| 632 | if (chroma444) { | 653 | filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0); |
| 633 | filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); | 654 | if (chroma) { |
| 634 | filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); | 655 | filter_mb_edgech(&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); |
| 635 | } else if( (edge&1) == 0 ) { | 656 | filter_mb_edgech(&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); |
| 636 | filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0); | 657 | } |
| 637 | filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0); | 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 | filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 ); | 756 | filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 ); |
| 727 | filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 ); | 757 | filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 ); |
| 728 | filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 ); | 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 | }else{ | 764 | }else{ |
| 730 | filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 ); | 765 | filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 ); |
| 731 | filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 ); | 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 | #if CONFIG_SMALL | 790 | #if CONFIG_SMALL |
| 756 | for( dir = 0; dir < 2; dir++ ) | 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 | #else | 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); | 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); |
| 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); | 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 | #endif | 796 | #endif |
| 762 | } | 797 | } |
| @@ -510,7 +510,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 509 unmodified lines | |||
| 510 | if(top_type){ | 510 | if(top_type){ |
| 511 | nnz = h->non_zero_count[top_xy]; | 511 | nnz = h->non_zero_count[top_xy]; |
| 512 | AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); | 512 | AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]); |
| 513 | if(CHROMA444){ | 513 | if(!s->chroma_y_shift){ |
| 514 | AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); | 514 | AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]); |
| 515 | AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); | 515 | AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]); |
| 516 | }else{ | 516 | }else{ |
| @@ -534,6 +534,11 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 17 unmodified lines | |||
| 534 | nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4]; | 534 | nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4]; |
| 535 | nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4]; | 535 | nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4]; |
| 536 | nnz_cache[3+8*12 + 2*8*i]= nnz[left_block[8+1+2*i]+8*4]; | 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 | }else{ | 542 | }else{ |
| 538 | nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]]; | 543 | nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]]; |
| 539 | nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]]; | 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 | #endif | 396 | #endif |
| 397 | sps->crop= get_bits1(&s->gb); | 397 | sps->crop= get_bits1(&s->gb); |
| 398 | if(sps->crop){ | 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 | sps->crop_left = get_ue_golomb(&s->gb); | 401 | sps->crop_left = get_ue_golomb(&s->gb); |
| 401 | sps->crop_right = get_ue_golomb(&s->gb); | 402 | sps->crop_right = get_ue_golomb(&s->gb); |
| 402 | sps->crop_top = get_ue_golomb(&s->gb); | 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 | if(sps->crop_left || sps->crop_top){ | 405 | if(sps->crop_left || sps->crop_top){ |
| 405 | av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n"); | 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 | av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, this could look slightly wrong ...\n"); | 409 | av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, this could look slightly wrong ...\n"); |
| 409 | } | 410 | } |
| 410 | }else{ | 411 | }else{ |
| @@ -80,7 +80,14 @@ static const uint8_t luma_dc_field_scan[16]={ · 79 unmodified lines | |||
| 80 | 80 | ||
| 81 | static const uint8_t chroma_dc_scan[4]={ | 81 | static const uint8_t chroma_dc_scan[4]={ |
| 82 | (0+0*2)*16, (1+0*2)*16, | 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 | // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)] | 93 | // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)] |
| @@ -41,7 +41,7 @@ · 40 unmodified lines | |||
| 41 | #include "h264dsp_template.c" | 41 | #include "h264dsp_template.c" |
| 42 | #undef BIT_DEPTH | 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 | #undef FUNC | 46 | #undef FUNC |
| 47 | #define FUNC(a, depth) a ## _ ## depth ## _c | 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 | 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 | 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 | c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\ | 60 | 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);\ | 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 | c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16x16, depth);\ | 67 | c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16x16, depth);\ |
| 62 | c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels16x8, depth);\ | 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 | c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\ | 92 | c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\ |
| 87 | c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\ | 93 | c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\ |
| 88 | c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\ | 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);\ | 95 | if (chroma_format_idc == 1)\ |
| 90 | c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\ | 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 | c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\ | 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);\ | 104 | if (chroma_format_idc == 1)\ |
| 93 | c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\ | 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 | c->h264_loop_filter_strength= NULL; | 112 | c->h264_loop_filter_strength= NULL; |
| 95 | 113 | ||
| 96 | switch (bit_depth) { | 114 | switch (bit_depth) { |
| @@ -105,7 +123,7 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) · 8 unmodified lines | |||
| 105 | break; | 123 | break; |
| 106 | } | 124 | } |
| 107 | 125 | ||
| 108 | if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth); | 126 | if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc); |
| 109 | if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth); | 127 | if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc); |
| 110 | if (HAVE_MMX) ff_h264dsp_init_x86(c, bit_depth); | 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 | void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); | 74 | void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul); |
| 75 | }H264DSPContext; | 75 | }H264DSPContext; |
| 76 | 76 | ||
| 77 | void ff_h264dsp_init(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); | 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); | 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); | 80 | void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); |
| 81 | 81 | ||
| 82 | #endif /* AVCODEC_H264DSP_H */ | 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 | FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 1, alpha, beta, tc0); | 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 | 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) | 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 | FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 1, alpha, beta); | 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 | * IDCT transforms the 16 dc values and dequantizes them. | 251 | * IDCT transforms the 16 dc values and dequantizes them. |
| 229 | * @param qmul quantization parameter | 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 | #undef stride | 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 | void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *_block, int qmul){ | 316 | void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *_block, int qmul){ |
| 267 | const int stride= 16*2; | 317 | const int stride= 16*2; |
| 268 | const int xStride= 16; | 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 | * Set the intra prediction function pointers. | 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 | // MpegEncContext * const s = &h->s; | 365 | // MpegEncContext * const s = &h->s; |
| 366 | 366 | ||
| 367 | #undef FUNC | 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 | h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\ | 434 | h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\ |
| 435 | h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\ | 435 | h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\ |
| 436 | \ | 436 | \ |
| 437 | h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\ | 437 | if (chroma_format_idc == 1) {\ |
| 438 | h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\ | 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 | if (codec_id != CODEC_ID_VP8) {\ | 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 | } else\ | 450 | } else\ |
| 442 | h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\ | 451 | h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\ |
| 443 | if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\ | 452 | if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\ |
| 444 | h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\ | 453 | if (chroma_format_idc == 1) {\ |
| 445 | h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\ | 454 | h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\ |
| 446 | h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\ | 455 | h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\ |
| 447 | h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ | 456 | h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\ |
| 448 | h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ | 457 | h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ |
| 449 | h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\ | 458 | h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ |
| 450 | h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, 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 | }else{\ | 470 | }else{\ |
| 452 | h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\ | 471 | h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\ |
| 453 | h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\ | 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 | h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\ | 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 | h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\ | 485 | h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\ |
| 463 | h->pred16x16[VERT_PRED8x8 ]= FUNCC(pred16x16_vertical , depth);\ | 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 | break; | 527 | break; |
| 505 | } | 528 | } |
| 506 | 529 | ||
| 507 | if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth); | 530 | if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc); |
| 508 | if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id, bit_depth); | 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 | void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); | 101 | void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); |
| 102 | }H264PredContext; | 102 | }H264PredContext; |
| 103 | 103 | ||
| 104 | void ff_h264_pred_init(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); | 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); | 106 | void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); |
| 107 | 107 | ||
| 108 | #endif /* AVCODEC_H264PRED_H */ | 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 | static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){ | 470 | static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){ |
| 458 | int i; | 471 | int i; |
| 459 | pixel *src = (pixel*)_src; | 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 | #define PRED8x8_X(n, v)\ | 493 | #define PRED8x8_X(n, v)\ |
| 470 | static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\ | 494 | static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\ |
| 471 | int i;\ | 495 | int i;\ |
| @@ -482,6 +506,11 @@ PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1); · 10 unmodified lines | |||
| 482 | PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0); | 506 | PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0); |
| 483 | PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1); | 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 | static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){ | 514 | static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){ |
| 486 | int i; | 515 | int i; |
| 487 | int dc0, dc2; | 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 | static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){ | 544 | static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){ |
| 511 | int i; | 545 | int i; |
| 512 | int dc0, dc1; | 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 | static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){ | 590 | static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){ |
| 536 | int i; | 591 | int i; |
| 537 | int dc0, dc1, dc2; | 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 | //the following 4 function should not be optimized! | 660 | //the following 4 function should not be optimized! |
| 564 | static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, int stride){ | 661 | static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, int stride){ |
| 565 | FUNCC(pred8x8_top_dc)(src, stride); | 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 | #define SRC(x,y) src[(x)+(y)*stride] | 759 | #define SRC(x,y) src[(x)+(y)*stride] |
| 622 | #define PL(y) \ | 760 | #define PL(y) \ |
| 623 | const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2; | 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 | if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { | 1004 | if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { |
| 1005 | if (bit_depth == 8) { | 1005 | if (bit_depth == 8) { |
| 1006 | c->h264_idct_add = ff_h264_idct_add_altivec; | 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 | c->h264_idct_add16 = ff_h264_idct_add16_altivec; | 1009 | c->h264_idct_add16 = ff_h264_idct_add16_altivec; |
| 1009 | c->h264_idct_add16intra = ff_h264_idct_add16intra_altivec; | 1010 | c->h264_idct_add16intra = ff_h264_idct_add16intra_altivec; |
| 1010 | c->h264_idct_dc_add= h264_idct_dc_add_altivec; | 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 | if (MPV_common_init(s) < 0) | 1343 | if (MPV_common_init(s) < 0) |
| 1344 | return -1; | 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 | #if CONFIG_RV30_DECODER | 1348 | #if CONFIG_RV30_DECODER |
| 1349 | if (avctx->codec_id == CODEC_ID_RV30) | 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 | avctx->pix_fmt = PIX_FMT_YUV420P; | 1769 | avctx->pix_fmt = PIX_FMT_YUV420P; |
| 1770 | 1770 | ||
| 1771 | dsputil_init(&s->dsp, avctx); | 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 | ff_vp8dsp_init(&s->vp8dsp); | 1773 | ff_vp8dsp_init(&s->vp8dsp); |
| 1774 | 1774 | ||
| 1775 | return 0; | 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 | void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride); | 167 | void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride); |
| 168 | void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride); | 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 | #if HAVE_YASM | 172 | #if HAVE_YASM |
| 173 | int mm_flags = av_get_cpu_flags(); | 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 | if (mm_flags & AV_CPU_FLAG_MMX) { | 176 | if (mm_flags & AV_CPU_FLAG_MMX) { |
| 177 | h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; | 177 | h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; |
| 178 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; | 178 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; |
| 179 | h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx; | 179 | if (chroma_format_idc == 1) { |
| 180 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; | 180 | h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx; |
| 181 | h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; | ||
| 182 | } | ||
| 181 | if (codec_id == CODEC_ID_VP8) { | 183 | if (codec_id == CODEC_ID_VP8) { |
| 182 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx; | 184 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx; |
| 183 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx; | 185 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx; |
| 184 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; | 186 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; |
| 185 | } else { | 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 | if (codec_id == CODEC_ID_SVQ3) { | 190 | if (codec_id == CODEC_ID_SVQ3) { |
| 188 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; | 191 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; |
| 189 | } else if (codec_id == CODEC_ID_RV40) { | 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 | if (mm_flags & AV_CPU_FLAG_MMX2) { | 200 | if (mm_flags & AV_CPU_FLAG_MMX2) { |
| 198 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; | 201 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; |
| 199 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; | 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 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; | 205 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; |
| 202 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; | 206 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; |
| 203 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; | 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 | h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; | 225 | h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; |
| 222 | } | 226 | } |
| 223 | if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { | 227 | if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { |
| 224 | h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; | 228 | if (chroma_format_idc == 1) { |
| 225 | h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; | 229 | h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; |
| 230 | h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; | ||
| 231 | } | ||
| 226 | } | 232 | } |
| 227 | if (codec_id == CODEC_ID_VP8) { | 233 | if (codec_id == CODEC_ID_VP8) { |
| 228 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmxext; | 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 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; | 237 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; |
| 232 | h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; | 238 | h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; |
| 233 | } else { | 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 | if (codec_id == CODEC_ID_SVQ3) { | 242 | if (codec_id == CODEC_ID_SVQ3) { |
| 236 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_mmx2; | 243 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_mmx2; |
| 237 | } else if (codec_id == CODEC_ID_RV40) { | 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 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2; | 264 | h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2; |
| 258 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2; | 265 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2; |
| 259 | } else { | 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 | if (codec_id == CODEC_ID_SVQ3) { | 269 | if (codec_id == CODEC_ID_SVQ3) { |
| 262 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; | 270 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; |
| 263 | } else if (codec_id == CODEC_ID_RV40) { | 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 | if (mm_flags & AV_CPU_FLAG_SSSE3) { | 279 | if (mm_flags & AV_CPU_FLAG_SSSE3) { |
| 272 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; | 280 | h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; |
| 273 | h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; | 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 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; | 284 | h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; |
| 276 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; | 285 | h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; |
| 277 | h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; | 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 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3; | 295 | h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3; |
| 287 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; | 296 | h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; |
| 288 | } else { | 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 | if (codec_id == CODEC_ID_SVQ3) { | 300 | if (codec_id == CODEC_ID_SVQ3) { |
| 291 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; | 301 | h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; |
| 292 | } else if (codec_id == CODEC_ID_RV40) { | 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 | h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; | 311 | h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; |
| 302 | h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; | 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 | h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext; | 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 | h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2; | 330 | h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2; |
| 320 | h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2; | 331 | h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2; |
| 321 | 332 | ||
| 322 | h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2; | 333 | if (chroma_format_idc == 1) { |
| 323 | h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2; | 334 | h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2; |
| 324 | h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2; | 335 | h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2; |
| 325 | h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2; | 336 | h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2; |
| 326 | h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_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 | h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2; | 341 | h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2; |
| 329 | h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_sse2; | 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 | H264_BIWEIGHT_10_SSE( 4, 4, 10) | 350 | H264_BIWEIGHT_10_SSE( 4, 4, 10) |
| 351 | H264_BIWEIGHT_10_SSE( 4, 2, 10) | 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 | int mm_flags = av_get_cpu_flags(); | 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 | c->h264_idct_add16 = ff_h264_idct_add16_8_mmx; | 369 | c->h264_idct_add16 = ff_h264_idct_add16_8_mmx; |
| 370 | c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmx; | 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 | c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmx; | 373 | c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmx; |
| 373 | c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_mmx; | 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 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmx2; | 378 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmx2; |
| 378 | c->h264_idct_add16 = ff_h264_idct_add16_8_mmx2; | 379 | c->h264_idct_add16 = ff_h264_idct_add16_8_mmx2; |
| 379 | c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmx2; | 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 | c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx2; | 383 | c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx2; |
| 382 | 384 | ||
| 383 | c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_8_mmxext; | 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 | c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_8_mmxext; | 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 | #if ARCH_X86_32 | 391 | #if ARCH_X86_32 |
| 388 | c->h264_v_loop_filter_luma= ff_deblock_v_luma_8_mmxext; | 392 | c->h264_v_loop_filter_luma= ff_deblock_v_luma_8_mmxext; |
| 389 | c->h264_h_loop_filter_luma= ff_deblock_h_luma_8_mmxext; | 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 | c->h264_idct_add16 = ff_h264_idct_add16_8_sse2; | 418 | c->h264_idct_add16 = ff_h264_idct_add16_8_sse2; |
| 415 | c->h264_idct8_add4 = ff_h264_idct8_add4_8_sse2; | 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 | c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2; | 422 | c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2; |
| 418 | c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_sse2; | 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 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_sse2; | 477 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_sse2; |
| 473 | 478 | ||
| 474 | c->h264_idct_add16 = ff_h264_idct_add16_10_sse2; | 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 | c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2; | 482 | c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2; |
| 477 | #if HAVE_ALIGNED_STACK | 483 | #if HAVE_ALIGNED_STACK |
| 478 | c->h264_idct8_add = ff_h264_idct8_add_10_sse2; | 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 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_avx; | 538 | c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_avx; |
| 533 | 539 | ||
| 534 | c->h264_idct_add16 = ff_h264_idct_add16_10_avx; | 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 | c->h264_idct_add16intra= ff_h264_idct_add16intra_10_avx; | 543 | c->h264_idct_add16intra= ff_h264_idct_add16intra_10_avx; |
| 537 | #if HAVE_ALIGNED_STACK | 544 | #if HAVE_ALIGNED_STACK |
| 538 | c->h264_idct8_add = ff_h264_idct8_add_10_avx; | 545 | c->h264_idct8_add = ff_h264_idct8_add_10_avx; |