History

h264: 4:2:2 intra decoding support

Baptiste Coudurier committed 15 years ago

Commit 76741b01 parent dc49bf124 files · +673 −133Browse files

Unified · Split

24 files
  1. Changelog +1 −0
  2. libavcodec/arm/h264dsp_init_arm.c +5 −4
  3. libavcodec/arm/h264pred_init_arm.c +3 −3
  4. libavcodec/dsputil.h +2 −0
  5. libavcodec/h264.c +72 −25
  6. libavcodec/h264.h +4 −8
  7. libavcodec/h264_cabac.c +75 −9
  8. libavcodec/h264_cavlc.c +120 −7
  9. libavcodec/h264_loopfilter.c +48 −13
  10. libavcodec/h264_mvpred.h +6 −1
  11. libavcodec/h264_ps.c +3 −2
  12. libavcodec/h264data.h +8 −1
  13. libavcodec/h264dsp.c +28 −10
  14. libavcodec/h264dsp.h +4 −4
  15. libavcodec/h264dsp_template.c +16 −0
  16. libavcodec/h264idct_template.c +50 −0
  17. libavcodec/h264pred.c +37 −14
  18. libavcodec/h264pred.h +3 −3
  19. libavcodec/h264pred_template.c +138 −0
  20. libavcodec/ppc/h264_altivec.c +3 −2
  21. libavcodec/rv34.c +1 −1
  22. libavcodec/vp8.c +1 −1
  23. libavcodec/x86/h264_intrapred_init.c +30 −17
  24. libavcodec/x86/h264dsp_mmx.c +15 −8
Changelog+1−0
@@ -54,6 +54,7 @@ easier to use. The changes are: · 53 unmodified lines
5454 - boxblur filter
5555 - Ut Video decoder
5656 - Speex encoding via libspeex
57+- 4:2:2 H.264 decoding support
5758
5859
5960 version 0.7:
libavcodec/arm/h264dsp_init_arm.c+5−4
@@ -92,7 +92,7 @@ void ff_h264_idct8_add4_neon(uint8_t *dst, const int *block_offset, · 91 unmodified lines
9292 DCTELEM *block, int stride,
9393 const uint8_t nnzc[6*8]);
9494
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)
9696 {
9797 if (bit_depth == 8) {
9898 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
122122 c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
123123 c->h264_idct_add16 = ff_h264_idct_add16_neon;
124124 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;
126127 c->h264_idct8_add = ff_h264_idct8_add_neon;
127128 c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon;
128129 c->h264_idct8_add4 = ff_h264_idct8_add4_neon;
129130 }
130131 }
131132
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)
133134 {
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);
135136 }
libavcodec/arm/h264pred_init_arm.c+3−3
@@ -42,7 +42,7 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, int stride); · 41 unmodified lines
4242 void ff_pred8x8_l00_dc_neon(uint8_t *src, int stride);
4343 void ff_pred8x8_0l0_dc_neon(uint8_t *src, int stride);
4444
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)
4646 {
4747 const int high_depth = bit_depth > 8;
4848
@@ -74,7 +74,7 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id, const int b · 25 unmodified lines
7474 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon;
7575 }
7676
77−void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth)
77+void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth, const int chroma_format_idc)
7878 {
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);
8080 }
libavcodec/dsputil.h+2−0
@@ -63,8 +63,10 @@ void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, DCTELEM *block, int strid · 62 unmodified lines
6363 void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\
6464 void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\
6565 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]);\
6667 void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]);\
6768 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);\
6870 void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(DCTELEM *block, int qmul);
6971
7072 H264_IDCT( 8)
libavcodec/h264.c+72−25
@@ -942,7 +942,7 @@ static void clone_tables(H264Context *dst, H264Context *src, int i){ · 941 unmodified lines
942942 dst->list_counts = src->list_counts;
943943
944944 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);
946946 }
947947
948948 /**
@@ -970,8 +970,8 @@ static av_cold void common_init(H264Context *h){ · 21 unmodified lines
970970 s->height = s->avctx->height;
971971 s->codec_id= s->avctx->codec->id;
972972
973− ff_h264dsp_init(&h->h264dsp, 8);
974− ff_h264_pred_init(&h->hpc, s->codec_id, 8);
973+ ff_h264dsp_init(&h->h264dsp, 8, 1);
974+ ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1);
975975
976976 h->dequant_coeff_pps= -1;
977977 s->unrestricted_mv=1;
@@ -1432,11 +1432,16 @@ static void decode_postinit(H264Context *h, int setup_finished){ · 454 unmodified lines
14321432 ff_thread_finish_setup(s->avctx);
14331433 }
14341434
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+{
14361439 MpegEncContext * const s = &h->s;
14371440 uint8_t *top_border;
14381441 int top_idx = 1;
14391442 const int pixel_shift = h->pixel_shift;
1443+ int chroma444 = CHROMA444;
1444+ int chroma422 = CHROMA422;
14401445
14411446 src_y -= linesize;
14421447 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
14601465 AV_COPY128(top_border+16, src_cb + 15*uvlinesize);
14611466 AV_COPY128(top_border+32, src_cr + 15*uvlinesize);
14621467 }
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+ }
14631476 } else {
14641477 if (pixel_shift) {
14651478 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
14951508 AV_COPY128(top_border+16, src_cb + 16*linesize);
14961509 AV_COPY128(top_border+32, src_cr + 16*linesize);
14971510 }
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+ }
14981519 } else {
14991520 if (pixel_shift) {
15001521 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
17731794 /* is_h264 should always be true if SVQ3 is disabled. */
17741795 const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264;
17751796 void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
1797+ const int block_h = 16 >> s->chroma_y_shift;
17761798
17771799 dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16;
1778− dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
1779− dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * 8;
1800+ dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift)*8 + mb_y * s->uvlinesize * block_h;
1801+ dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift)*8 + mb_y * s->uvlinesize * block_h;
17801802
17811803 s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + (64 << pixel_shift), s->linesize, 4);
17821804 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
17891811 block_offset = &h->block_offset[48];
17901812 if(mb_y&1){ //FIXME move out of this function?
17911813 dest_y -= s->linesize*15;
1792− dest_cb-= s->uvlinesize*7;
1793− dest_cr-= s->uvlinesize*7;
1814+ dest_cb-= s->uvlinesize * (block_h - 1);
1815+ dest_cr-= s->uvlinesize * (block_h - 1);
17941816 }
17951817 if(FRAME_MBAFF) {
17961818 int list;
@@ -1842,12 +1864,12 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 45 unmodified lines
18421864 }
18431865 }
18441866 } else {
1845− for (i = 0; i < 8; i++) {
1867+ for (i = 0; i < block_h; i++) {
18461868 uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize);
18471869 for (j = 0; j < 8; j++)
18481870 tmp_cb[j] = get_bits(&gb, bit_depth);
18491871 }
1850− for (i = 0; i < 8; i++) {
1872+ for (i = 0; i < block_h; i++) {
18511873 uint16_t *tmp_cr = (uint16_t*)(dest_cr + i*uvlinesize);
18521874 for (j = 0; j < 8; j++)
18531875 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
18651887 memset(dest_cr + i*uvlinesize, 128, 8);
18661888 }
18671889 } else {
1868− for (i = 0; i < 8; i++) {
1890+ for (i = 0; i < block_h; i++) {
18691891 memcpy(dest_cb + i*uvlinesize, h->mb + 128 + i*4, 8);
18701892 memcpy(dest_cr + i*uvlinesize, h->mb + 160 + i*4, 8);
18711893 }
@@ -1913,10 +1935,18 @@ static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, i · 41 unmodified lines
19131935 }
19141936 }else{
19151937 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+ }
19161946 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]);
19181948 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]);
19201950 h->h264dsp.h264_idct_add8(dest, block_offset,
19211951 h->mb, uvlinesize,
19221952 h->non_zero_count_cache);
@@ -2555,11 +2585,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ · 632 unmodified lines
25552585
25562586 h->b_stride= s->mb_width*4;
25572587
2588+ s->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p
2589+
25582590 s->width = 16*s->mb_width - (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1);
25592591 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);
25612593 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);
25632595
25642596 if (s->context_initialized
25652597 && ( 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
26012633
26022634 switch (h->sps.bit_depth_luma) {
26032635 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;
26052642 break;
26062643 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;
26082650 break;
26092651 default:
26102652 if (CHROMA444){
26112653 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;
26122656 }else{
26132657 s->avctx->pix_fmt = s->avctx->get_format(s->avctx,
26142658 s->avctx->codec->pix_fmts ?
@@ -3272,6 +3316,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ · 657 unmodified lines
32723316 const int end_mb_y= s->mb_y + FRAME_MBAFF;
32733317 const int old_slice_type= h->slice_type;
32743318 const int pixel_shift = h->pixel_shift;
3319+ const int block_h = 16 >> s->chroma_y_shift;
32753320
32763321 if(h->deblocking_filter) {
32773322 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
32883333 s->mb_x= mb_x;
32893334 s->mb_y= mb_y;
32903335 dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16;
3291− dest_cb = s->current_picture.f.data[1] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
3292− dest_cr = s->current_picture.f.data[2] + ((mb_x << pixel_shift) + mb_y * s->uvlinesize) * (8 << CHROMA444);
3336+ dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h;
3337+ dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h;
32933338 //FIXME simplify above
32943339
32953340 if (MB_FIELD) {
@@ -3297,14 +3342,14 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ · 1 unmodified line
32973342 uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;
32983343 if(mb_y&1){ //FIXME move out of this function?
32993344 dest_y -= s->linesize*15;
3300− dest_cb-= s->uvlinesize*((8 << CHROMA444)-1);
3301− dest_cr-= s->uvlinesize*((8 << CHROMA444)-1);
3345+ dest_cb-= s->uvlinesize * (block_h - 1);
3346+ dest_cr-= s->uvlinesize * (block_h - 1);
33023347 }
33033348 } else {
33043349 linesize = h->mb_linesize = s->linesize;
33053350 uvlinesize = h->mb_uvlinesize = s->uvlinesize;
33063351 }
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);
33083353 if(fill_filter_caches(h, mb_type))
33093354 continue;
33103355 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
37423787 if(avctx->has_b_frames < 2)
37433788 avctx->has_b_frames= !s->low_delay;
37443789
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) {
37463792 if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 10) {
37473793 avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
3794+ h->cur_chroma_format_idc = h->sps.chroma_format_idc;
37483795 h->pixel_shift = h->sps.bit_depth_luma > 8;
37493796
3750− ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma);
3751− ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma);
3797+ ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma, h->sps.chroma_format_idc);
3798+ ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma, h->sps.chroma_format_idc);
37523799 s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
37533800 dsputil_init(&s->dsp, s->avctx);
37543801 } else {
libavcodec/h264.h+4−8
@@ -39,13 +39,6 @@ · 38 unmodified lines
3939 #define interlaced_dct interlaced_dct_is_a_bad_name
4040 #define mb_intra mb_intra_is_not_initialized_see_mb_type
4141
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−
4942 #define MAX_SPS_COUNT 32
5043 #define MAX_PPS_COUNT 256
5144
@@ -92,6 +85,7 @@ · 40 unmodified lines
9285 #define CABAC h->pps.cabac
9386 #endif
9487
88+#define CHROMA422 (h->sps.chroma_format_idc == 2)
9589 #define CHROMA444 (h->sps.chroma_format_idc == 3)
9690
9791 #define EXTENDED_SAR 255
@@ -582,6 +576,8 @@ typedef struct H264Context{ · 484 unmodified lines
582576 // Timestamp stuff
583577 int sei_buffering_period_present; ///< Buffering period SEI flag
584578 int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
579+
580+ int cur_chroma_format_idc;
585581 }H264Context;
586582
587583
@@ -809,7 +805,7 @@ static av_always_inline void write_back_non_zero_count(H264Context *h){ · 221 unmodified lines
809805 AV_COPY32(&nnz[32], &nnz_cache[4+8*11]);
810806 AV_COPY32(&nnz[36], &nnz_cache[4+8*12]);
811807
812− if(CHROMA444){
808+ if(!h->s.chroma_y_shift){
813809 AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]);
814810 AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]);
815811 AV_COPY32(&nnz[40], &nnz_cache[4+8*13]);
libavcodec/h264_cabac.c+75−9
@@ -1565,7 +1565,12 @@ DECLARE_ASM_CONST(1, uint8_t, last_coeff_flag_offset_8x8)[63] = { · 1564 unmodified lines
15651565 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
15661566 };
15671567
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+{
15691574 static const int significant_coeff_flag_offset[2][14] = {
15701575 { 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 },
15711576 { 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
15871592 9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
15881593 9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }
15891594 };
1595+ static const uint8_t sig_coeff_offset_dc[7] = { 0, 0, 1, 1, 2, 2, 2 };
15901596 /* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
15911597 * 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
15921598 * map node ctx => cabac ctx for level=1 */
15931599 static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
15941600 /* 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+ };
15961605 static const uint8_t coeff_abs_level_transition[2][8] = {
15971606 /* update node ctx after decoding a level=1 */
15981607 { 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
16511660 coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index,
16521661 last_coeff_ctx_base, sig_off);
16531662 } else {
1654− coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index,
1655− last_coeff_ctx_base-significant_coeff_ctx_base);
1663+ if (is_dc && chroma422) { // dc 422
1664+ DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]);
1665+ } else {
1666+ coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index,
1667+ last_coeff_ctx_base-significant_coeff_ctx_base);
1668+ }
16561669 #else
16571670 DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] );
16581671 } 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+ }
16601677 #endif
16611678 }
16621679 assert(coeff_count > 0);
@@ -1691,7 +1708,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT · 28 unmodified lines
16911708 } \
16921709 } else { \
16931710 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; \
16951712 node_ctx = coeff_abs_level_transition[1][node_ctx]; \
16961713 \
16971714 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
17331750 }
17341751
17351752 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);
17371761 }
17381762
17391763 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);
17411765 }
17421766
17431767 /* 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
17611785 decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff );
17621786 }
17631787
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+
17641801 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 ) {
17651802 /* read coded block flag */
17661803 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
23132350 if(CHROMA444){
23142351 decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1);
23152352 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 */ {
23172383 if( cbp&0x30 ){
23182384 int c;
23192385 for( c = 0; c < 2; c++ ) {
libavcodec/h264_cavlc.c+120−7
@@ -62,6 +62,30 @@ static const uint8_t chroma_dc_coeff_token_bits[4*5]={ · 61 unmodified lines
6262 2, 3, 2, 0,
6363 };
6464
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+
6589 static const uint8_t coeff_token_len[4][4*17]={
6690 {
6791 1, 0, 0, 0,
@@ -172,6 +196,26 @@ static const uint8_t chroma_dc_total_zeros_bits[3][4]= { · 104 unmodified lines
172196 { 1, 0, 0, 0,},
173197 };
174198
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+
175219 static const uint8_t run_len[7][16]={
176220 {1,1},
177221 {1,2,2},
@@ -200,6 +244,10 @@ static VLC chroma_dc_coeff_token_vlc; · 22 unmodified lines
200244 static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2];
201245 static const int chroma_dc_coeff_token_vlc_table_size = 256;
202246
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+
203251 static VLC total_zeros_vlc[15];
204252 static VLC_TYPE total_zeros_vlc_tables[15][512][2];
205253 static const int total_zeros_vlc_tables_size = 512;
@@ -208,6 +256,10 @@ static VLC chroma_dc_total_zeros_vlc[3]; · 2 unmodified lines
208256 static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2];
209257 static const int chroma_dc_total_zeros_vlc_tables_size = 8;
210258
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+
211263 static VLC run_vlc[6];
212264 static VLC_TYPE run_vlc_tables[6][8][2];
213265 static const int run_vlc_tables_size = 8;
@@ -219,6 +271,14 @@ static const int run7_vlc_table_size = 96; · 5 unmodified lines
219271 #define LEVEL_TAB_BITS 8
220272 static int8_t cavlc_level_tab[7][1<<LEVEL_TAB_BITS][2];
221273
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
222282
223283 /**
224284 * gets the predicted number of non-zero coefficients.
@@ -278,6 +338,13 @@ av_cold void ff_h264_decode_init_vlc(void){ · 53 unmodified lines
278338 &chroma_dc_coeff_token_bits[0], 1, 1,
279339 INIT_VLC_USE_NEW_STATIC);
280340
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+
281348 offset = 0;
282349 for(i=0; i<4; i++){
283350 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
304371 &chroma_dc_total_zeros_bits[i][0], 1, 1,
305372 INIT_VLC_USE_NEW_STATIC);
306373 }
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+
307385 for(i=0; i<15; i++){
308386 total_zeros_vlc[i].table = total_zeros_vlc_tables[i];
309387 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
373451 //FIXME put trailing_onex into the context
374452
375453 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);
377458 total_coeff= coeff_token>>2;
378459 }else{
379460 if(n >= LUMA_DC_BLOCK_INDEX){
@@ -483,11 +564,16 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in · 103 unmodified lines
483564 if(total_coeff == max_coeff)
484565 zeros_left=0;
485566 else{
486− /* FIXME: we don't actually support 4:2:2 yet. */
487− if(max_coeff <= 8)
488− zeros_left= get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[ total_coeff ].table, CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1);
489− else
567+ if (max_coeff <= 8) {
568+ if (max_coeff == 4)
569+ zeros_left = get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[total_coeff].table,
570+ CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1);
571+ else
572+ zeros_left = get_vlc2(gb, (chroma422_dc_total_zeros_vlc-1)[total_coeff].table,
573+ CHROMA422_DC_TOTAL_ZEROS_VLC_BITS, 1);
574+ } else {
490575 zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1);
576+ }
491577 }
492578
493579 #define STORE_BLOCK(type) \
@@ -994,7 +1080,7 @@ decode_intra_mb: · 500 unmodified lines
9941080 s->current_picture.f.mb_type[mb_xy] = mb_type;
9951081
9961082 if(cbp || IS_INTRA16x16(mb_type)){
997− int i4x4, chroma_idx;
1083+ int i4x4, i8x8, chroma_idx;
9981084 int dquant;
9991085 int ret;
10001086 GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr;
@@ -1036,7 +1122,34 @@ decode_intra_mb: · 35 unmodified lines
10361122 if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ){
10371123 return -1;
10381124 }
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 */ {
10401153 if(cbp&0x30){
10411154 for(chroma_idx=0; chroma_idx<2; chroma_idx++)
10421155 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){
libavcodec/h264_loopfilter.c+48−13
@@ -212,6 +212,7 @@ static void av_always_inline h264_filter_mb_fast_internal( H264Context *h, int m · 211 unmodified lines
212212 MpegEncContext * const s = &h->s;
213213 int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
214214 int chroma444 = CHROMA444;
215+ int chroma422 = CHROMA422;
215216
216217 int mb_xy = h->mb_xy;
217218 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
289290 filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
290291 filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
291292 }
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);
292310 }else{
293311 if(left_type){
294312 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
411429 return v;
412430 }
413431
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) {
415433 MpegEncContext * const s = &h->s;
416434 int edge;
417435 int chroma_qp_avg[2];
436+ int chroma444 = CHROMA444;
437+ int chroma422 = CHROMA422;
418438 const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy;
419439 const int mbm_type = dir == 0 ? h->left_type[LTOP] : h->top_type;
420440
@@ -564,8 +584,9 @@ static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, u · 143 unmodified lines
564584 for( edge = 1; edge < edges; edge++ ) {
565585 DECLARE_ALIGNED(8, int16_t, bS)[4];
566586 int qp;
587+ const int deblock_edge = !IS_8x8DCT(mb_type & (edge<<24)); // (edge&1) && IS_8x8DCT(mb_type)
567588
568− if( IS_8x8DCT(mb_type & (edge<<24)) ) // (edge&1) && IS_8x8DCT(mb_type)
589+ if (!deblock_edge && (!chroma422 || dir == 0))
569590 continue;
570591
571592 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
627648 }
628649 }
629650 } else {
630− filter_mb_edgeh( &img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0 );
631− if (chroma) {
632− if (chroma444) {
633− filter_mb_edgeh ( &img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
634− filter_mb_edgeh ( &img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
635− } else if( (edge&1) == 0 ) {
636− filter_mb_edgech( &img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
637− filter_mb_edgech( &img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
651+ if (chroma422) {
652+ if (deblock_edge)
653+ filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0);
654+ if (chroma) {
655+ filter_mb_edgech(&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
656+ filter_mb_edgech(&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
657+ }
658+ } else {
659+ filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0);
660+ if (chroma) {
661+ if (chroma444) {
662+ filter_mb_edgeh (&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
663+ filter_mb_edgeh (&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
664+ } else if ((edge&1) == 0) {
665+ filter_mb_edgech(&img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
666+ filter_mb_edgech(&img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
667+ }
638668 }
639669 }
640670 }
@@ -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
726756 filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
727757 filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
728758 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);
729764 }else{
730765 filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
731766 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
754789
755790 #if CONFIG_SMALL
756791 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);
758793 #else
759− filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, CHROMA444, 0);
760− filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, CHROMA444, 1);
794+ filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
795+ filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
761796 #endif
762797 }
libavcodec/h264_mvpred.h+6−1
@@ -510,7 +510,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 509 unmodified lines
510510 if(top_type){
511511 nnz = h->non_zero_count[top_xy];
512512 AV_COPY32(&nnz_cache[4+8* 0], &nnz[4*3]);
513− if(CHROMA444){
513+ if(!s->chroma_y_shift){
514514 AV_COPY32(&nnz_cache[4+8* 5], &nnz[4* 7]);
515515 AV_COPY32(&nnz_cache[4+8*10], &nnz[4*11]);
516516 }else{
@@ -534,6 +534,11 @@ static void fill_decode_caches(H264Context *h, int mb_type){ · 17 unmodified lines
534534 nnz_cache[3+8* 7 + 2*8*i]= nnz[left_block[8+1+2*i]+4*4];
535535 nnz_cache[3+8*11 + 2*8*i]= nnz[left_block[8+0+2*i]+8*4];
536536 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];
537542 }else{
538543 nnz_cache[3+8* 6 + 8*i]= nnz[left_block[8+4+2*i]];
539544 nnz_cache[3+8*11 + 8*i]= nnz[left_block[8+5+2*i]];
libavcodec/h264_ps.c+3−2
@@ -396,7 +396,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ · 395 unmodified lines
396396 #endif
397397 sps->crop= get_bits1(&s->gb);
398398 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;
400401 sps->crop_left = get_ue_golomb(&s->gb);
401402 sps->crop_right = get_ue_golomb(&s->gb);
402403 sps->crop_top = get_ue_golomb(&s->gb);
@@ -404,7 +405,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ · 1 unmodified line
404405 if(sps->crop_left || sps->crop_top){
405406 av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ...\n");
406407 }
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){
408409 av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, this could look slightly wrong ...\n");
409410 }
410411 }else{
libavcodec/h264data.h+8−1
@@ -80,7 +80,14 @@ static const uint8_t luma_dc_field_scan[16]={ · 79 unmodified lines
8080
8181 static const uint8_t chroma_dc_scan[4]={
8282 (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,
8491 };
8592
8693 // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)]
libavcodec/h264dsp.c+28−10
@@ -41,7 +41,7 @@ · 40 unmodified lines
4141 #include "h264dsp_template.c"
4242 #undef BIT_DEPTH
4343
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)
4545 {
4646 #undef FUNC
4747 #define FUNC(a, depth) a ## _ ## depth ## _c
@@ -53,10 +53,16 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) · 5 unmodified lines
5353 c->h264_idct8_dc_add= FUNC(ff_h264_idct8_dc_add, depth);\
5454 c->h264_idct_add16 = FUNC(ff_h264_idct_add16, depth);\
5555 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);\
5760 c->h264_idct_add16intra= FUNC(ff_h264_idct_add16intra, depth);\
5861 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);\
6066 \
6167 c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16x16, depth);\
6268 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
8692 c->h264_h_loop_filter_luma_intra= FUNC(h264_h_loop_filter_luma_intra, depth);\
8793 c->h264_h_loop_filter_luma_mbaff_intra= FUNC(h264_h_loop_filter_luma_mbaff_intra, depth);\
8894 c->h264_v_loop_filter_chroma= FUNC(h264_v_loop_filter_chroma, depth);\
89− c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
90− c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
95+ if (chroma_format_idc == 1)\
96+ c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma, depth);\
97+ else\
98+ c->h264_h_loop_filter_chroma= FUNC(h264_h_loop_filter_chroma422, depth);\
99+ if (chroma_format_idc == 1)\
100+ c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma_mbaff, depth);\
101+ else\
102+ c->h264_h_loop_filter_chroma_mbaff= FUNC(h264_h_loop_filter_chroma422_mbaff, depth);\
91103 c->h264_v_loop_filter_chroma_intra= FUNC(h264_v_loop_filter_chroma_intra, depth);\
92− c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
93− c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
104+ if (chroma_format_idc == 1)\
105+ c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma_intra, depth);\
106+ else\
107+ c->h264_h_loop_filter_chroma_intra= FUNC(h264_h_loop_filter_chroma422_intra, depth);\
108+ if (chroma_format_idc == 1)\
109+ c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma_mbaff_intra, depth);\
110+ else\
111+ c->h264_h_loop_filter_chroma_mbaff_intra= FUNC(h264_h_loop_filter_chroma422_mbaff_intra, depth);\
94112 c->h264_loop_filter_strength= NULL;
95113
96114 switch (bit_depth) {
@@ -105,7 +123,7 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth) · 8 unmodified lines
105123 break;
106124 }
107125
108− if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth);
109− if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth);
110− if (HAVE_MMX) ff_h264dsp_init_x86(c, bit_depth);
126+ if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
127+ if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
128+ if (HAVE_MMX) ff_h264dsp_init_x86(c, bit_depth, chroma_format_idc);
111129 }
libavcodec/h264dsp.h+4−4
@@ -74,9 +74,9 @@ typedef struct H264DSPContext{ · 73 unmodified lines
7474 void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul);
7575 }H264DSPContext;
7676
77−void ff_h264dsp_init(H264DSPContext *c, const int bit_depth);
78−void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth);
79−void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth);
80−void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth);
77+void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);
78+void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);
79+void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);
80+void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);
8181
8282 #endif /* AVCODEC_H264DSP_H */
libavcodec/h264dsp_template.c+16−0
@@ -275,6 +275,14 @@ static void FUNCC(h264_h_loop_filter_chroma_mbaff)(uint8_t *pix, int stride, int · 274 unmodified lines
275275 {
276276 FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 1, alpha, beta, tc0);
277277 }
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+}
278286
279287 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)
280288 {
@@ -312,3 +320,11 @@ static void FUNCC(h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix, int strid · 31 unmodified lines
312320 {
313321 FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 1, alpha, beta);
314322 }
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+}
libavcodec/h264idct_template.c+50−0
@@ -224,6 +224,29 @@ void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, DCTELEM * · 223 unmodified lines
224224 }
225225 }
226226 }
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+
227250 /**
228251 * IDCT transforms the 16 dc values and dequantizes them.
229252 * @param qmul quantization parameter
@@ -263,6 +286,33 @@ void FUNCC(ff_h264_luma_dc_dequant_idct)(DCTELEM *_output, DCTELEM *_input, int · 33 unmodified lines
263286 #undef stride
264287 }
265288
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+
266316 void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *_block, int qmul){
267317 const int stride= 16*2;
268318 const int xStride= 16;
libavcodec/h264pred.c+37−14
@@ -361,7 +361,7 @@ static void pred8x8_tm_vp8_c(uint8_t *src, int stride){ · 360 unmodified lines
361361 /**
362362 * Set the intra prediction function pointers.
363363 */
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){
365365 // MpegEncContext * const s = &h->s;
366366
367367 #undef FUNC
@@ -434,20 +434,39 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth){ · 66 unmodified lines
434434 h->pred8x8l[TOP_DC_PRED ]= FUNCC(pred8x8l_top_dc , depth);\
435435 h->pred8x8l[DC_128_PRED ]= FUNCC(pred8x8l_128_dc , depth);\
436436 \
437− h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\
438− h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\
437+ if (chroma_format_idc == 1) {\
438+ h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\
439+ h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\
440+ } else {\
441+ h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x16_vertical , depth);\
442+ h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\
443+ }\
439444 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+ }\
441450 } else\
442451 h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\
443452 if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){\
444− h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
445− h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
446− h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\
447− h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\
448− h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\
449− h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
450− h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
453+ if (chroma_format_idc == 1) {\
454+ h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\
455+ h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\
456+ h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x8_top_dc , depth);\
457+ h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\
458+ h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\
459+ h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
460+ h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
461+ } else {\
462+ h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x16_dc , depth);\
463+ h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x16_left_dc , depth);\
464+ h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x16_top_dc , depth);\
465+ h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\
466+ h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\
467+ h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
468+ h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
469+ }\
451470 }else{\
452471 h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\
453472 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
457476 h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\
458477 }\
459478 }\
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+ }\
461484 \
462485 h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\
463486 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
504527 break;
505528 }
506529
507− if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth);
508− if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id, bit_depth);
530+ if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
531+ if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
509532 }
libavcodec/h264pred.h+3−3
@@ -101,8 +101,8 @@ typedef struct H264PredContext{ · 100 unmodified lines
101101 void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride);
102102 }H264PredContext;
103103
104−void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth);
105−void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth);
106−void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth);
104+void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc);
105+void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc);
106+void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc);
107107
108108 #endif /* AVCODEC_H264PRED_H */
libavcodec/h264pred_template.c+138−0
@@ -454,6 +454,19 @@ static void FUNCC(pred8x8_vertical)(uint8_t *_src, int _stride){ · 453 unmodified lines
454454 }
455455 }
456456
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+
457470 static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){
458471 int i;
459472 pixel *src = (pixel*)_src;
@@ -466,6 +479,17 @@ static void FUNCC(pred8x8_horizontal)(uint8_t *_src, int stride){ · 6 unmodified lines
466479 }
467480 }
468481
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+
469493 #define PRED8x8_X(n, v)\
470494 static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, int stride){\
471495 int i;\
@@ -482,6 +506,11 @@ PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1); · 10 unmodified lines
482506 PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0);
483507 PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1);
484508
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+
485514 static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){
486515 int i;
487516 int dc0, dc2;
@@ -507,6 +536,11 @@ static void FUNCC(pred8x8_left_dc)(uint8_t *_src, int stride){ · 19 unmodified lines
507536 }
508537 }
509538
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+
510544 static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){
511545 int i;
512546 int dc0, dc1;
@@ -532,6 +566,27 @@ static void FUNCC(pred8x8_top_dc)(uint8_t *_src, int stride){ · 19 unmodified lines
532566 }
533567 }
534568
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+
535590 static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){
536591 int i;
537592 int dc0, dc1, dc2;
@@ -560,6 +615,48 @@ static void FUNCC(pred8x8_dc)(uint8_t *_src, int stride){ · 22 unmodified lines
560615 }
561616 }
562617
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+
563660 //the following 4 function should not be optimized!
564661 static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, int stride){
565662 FUNCC(pred8x8_top_dc)(src, stride);
@@ -618,6 +715,47 @@ static void FUNCC(pred8x8_plane)(uint8_t *_src, int _stride){ · 52 unmodified lines
618715 }
619716 }
620717
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+
621759 #define SRC(x,y) src[(x)+(y)*stride]
622760 #define PL(y) \
623761 const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
libavcodec/ppc/h264_altivec.c+3−2
@@ -999,12 +999,13 @@ void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) { · 998 unmodified lines
999999 }
10001000 }
10011001
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)
10031003 {
10041004 if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) {
10051005 if (bit_depth == 8) {
10061006 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;
10081009 c->h264_idct_add16 = ff_h264_idct_add16_altivec;
10091010 c->h264_idct_add16intra = ff_h264_idct_add16intra_altivec;
10101011 c->h264_idct_dc_add= h264_idct_dc_add_altivec;
libavcodec/rv34.c+1−1
@@ -1343,7 +1343,7 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) · 1342 unmodified lines
13431343 if (MPV_common_init(s) < 0)
13441344 return -1;
13451345
1346− ff_h264_pred_init(&r->h, CODEC_ID_RV40, 8);
1346+ ff_h264_pred_init(&r->h, CODEC_ID_RV40, 8, 1);
13471347
13481348 #if CONFIG_RV30_DECODER
13491349 if (avctx->codec_id == CODEC_ID_RV30)
libavcodec/vp8.c+1−1
@@ -1769,7 +1769,7 @@ static av_cold int vp8_decode_init(AVCodecContext *avctx) · 1768 unmodified lines
17691769 avctx->pix_fmt = PIX_FMT_YUV420P;
17701770
17711771 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);
17731773 ff_vp8dsp_init(&s->vp8dsp);
17741774
17751775 return 0;
libavcodec/x86/h264_intrapred_init.c+30−17
@@ -167,7 +167,7 @@ void ff_pred4x4_tm_vp8_mmxext (uint8_t *src, const uint8_t *topright, int s · 166 unmodified lines
167167 void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride);
168168 void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride);
169169
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)
171171 {
172172 #if HAVE_YASM
173173 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
176176 if (mm_flags & AV_CPU_FLAG_MMX) {
177177 h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx;
178178 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx;
179− h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx;
180− h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
179+ if (chroma_format_idc == 1) {
180+ h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx;
181+ h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx;
182+ }
181183 if (codec_id == CODEC_ID_VP8) {
182184 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx;
183185 h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx;
184186 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx;
185187 } 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;
187190 if (codec_id == CODEC_ID_SVQ3) {
188191 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx;
189192 } 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
197200 if (mm_flags & AV_CPU_FLAG_MMX2) {
198201 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
199202 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;
201205 h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
202206 h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext;
203207 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
221225 h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext;
222226 }
223227 if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
224− h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
225− h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
228+ if (chroma_format_idc == 1) {
229+ h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
230+ h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
231+ }
226232 }
227233 if (codec_id == CODEC_ID_VP8) {
228234 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
231237 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext;
232238 h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext;
233239 } 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;
235242 if (codec_id == CODEC_ID_SVQ3) {
236243 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_mmx2;
237244 } 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
257264 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2;
258265 h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2;
259266 } 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;
261269 if (codec_id == CODEC_ID_SVQ3) {
262270 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2;
263271 } 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
271279 if (mm_flags & AV_CPU_FLAG_SSSE3) {
272280 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
273281 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;
275284 h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
276285 h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3;
277286 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
286295 h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3;
287296 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3;
288297 } 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;
290300 if (codec_id == CODEC_ID_SVQ3) {
291301 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3;
292302 } 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
301311 h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext;
302312 h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext;
303313
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;
305316
306317 h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext;
307318
@@ -319,11 +330,13 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth · 11 unmodified lines
319330 h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2;
320331 h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2;
321332
322− h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2;
323− h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2;
324− h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2;
325− h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2;
326− h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2;
333+ if (chroma_format_idc == 1) {
334+ h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2;
335+ h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2;
336+ h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2;
337+ h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2;
338+ h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2;
339+ }
327340
328341 h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2;
329342 h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_sse2;
libavcodec/x86/h264dsp_mmx.c+15−8
@@ -350,7 +350,7 @@ H264_BIWEIGHT_10_SSE( 4, 8, 10) · 349 unmodified lines
350350 H264_BIWEIGHT_10_SSE( 4, 4, 10)
351351 H264_BIWEIGHT_10_SSE( 4, 2, 10)
352352
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)
354354 {
355355 int mm_flags = av_get_cpu_flags();
356356
@@ -368,7 +368,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 11 unmodified lines
368368
369369 c->h264_idct_add16 = ff_h264_idct_add16_8_mmx;
370370 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;
372373 c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmx;
373374 c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_mmx;
374375
@@ -377,13 +378,16 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 2 unmodified lines
377378 c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmx2;
378379 c->h264_idct_add16 = ff_h264_idct_add16_8_mmx2;
379380 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;
381383 c->h264_idct_add16intra= ff_h264_idct_add16intra_8_mmx2;
382384
383385 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;
385386 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+ }
387391 #if ARCH_X86_32
388392 c->h264_v_loop_filter_luma= ff_deblock_v_luma_8_mmxext;
389393 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
413417
414418 c->h264_idct_add16 = ff_h264_idct_add16_8_sse2;
415419 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;
417422 c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2;
418423 c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_sse2;
419424
@@ -472,7 +477,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth) · 52 unmodified lines
472477 c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_sse2;
473478
474479 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;
476482 c->h264_idct_add16intra= ff_h264_idct_add16intra_10_sse2;
477483 #if HAVE_ALIGNED_STACK
478484 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
532538 c->h264_idct8_dc_add = ff_h264_idct8_dc_add_10_avx;
533539
534540 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;
536543 c->h264_idct_add16intra= ff_h264_idct_add16intra_10_avx;
537544 #if HAVE_ALIGNED_STACK
538545 c->h264_idct8_add = ff_h264_idct8_add_10_avx;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t