Mercurial > libavcodec.hg
comparison h263.c @ 144:cb5dabd00ba2 libavcodec
- Bug fix on inter MCBPC table for inter+q.
- H.263/H.263+ decoder now knows GOB start codes.
- H.263/H.263+ decoder now returns the size of the stream on the first call.
- Added show_bits() functions to see the buffer without loosing the bits.
- TODO: H.263v1 UMV parsing is buggy.
author | pulento |
---|---|
date | Sat, 03 Nov 2001 00:49:53 +0000 |
parents | e00e5d93457c |
children | f914f710b8d0 |
comparison
equal
deleted
inserted
replaced
143:35e3ced6cfd9 | 144:cb5dabd00ba2 |
---|---|
35 static int h263p_decode_umotion(MpegEncContext * s, int pred); | 35 static int h263p_decode_umotion(MpegEncContext * s, int pred); |
36 static int h263_decode_block(MpegEncContext * s, DCTELEM * block, | 36 static int h263_decode_block(MpegEncContext * s, DCTELEM * block, |
37 int n, int coded); | 37 int n, int coded); |
38 static int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, | 38 static int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block, |
39 int n, int coded); | 39 int n, int coded); |
40 | |
41 | 40 |
42 int h263_get_picture_format(int width, int height) | 41 int h263_get_picture_format(int width, int height) |
43 { | 42 { |
44 int format; | 43 int format; |
45 | 44 |
775 | 774 |
776 int h263_decode_mb(MpegEncContext *s, | 775 int h263_decode_mb(MpegEncContext *s, |
777 DCTELEM block[6][64]) | 776 DCTELEM block[6][64]) |
778 { | 777 { |
779 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; | 778 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; |
779 unsigned int val; | |
780 INT16 *mot_val; | 780 INT16 *mot_val; |
781 static INT8 quant_tab[4] = { -1, -2, 1, 2 }; | 781 static INT8 quant_tab[4] = { -1, -2, 1, 2 }; |
782 | 782 |
783 /* Check for GOB Start Code */ | |
784 val = show_bits(&s->gb, 16); | |
785 | |
786 if (val == 0) { | |
787 /* We have a GBSC probably with GSTUFF */ | |
788 #ifdef DEBUG | |
789 unsigned int gn, gfid; | |
790 #endif | |
791 //skip_bits(&s->gb, 16); /* Drop the zeros */ | |
792 while (get_bits1(&s->gb) == 0); /* Seek the '1' bit */ | |
793 #ifdef DEBUG | |
794 fprintf(stderr,"\nGOB Start Code at MB %d\n", | |
795 (s->mb_y * s->mb_width) + s->mb_x); | |
796 gn = get_bits(&s->gb, 5); /* GN */ | |
797 gfid = get_bits(&s->gb, 2); /* GFID */ | |
798 #else | |
799 skip_bits(&s->gb, 5); /* GN */ | |
800 skip_bits(&s->gb, 2); /* GFID */ | |
801 #endif | |
802 s->qscale = get_bits(&s->gb, 5); /* GQUANT */ | |
803 #ifdef DEBUG | |
804 fprintf(stderr, "\nGN: %u GFID: %u Quant: %u\n", gn, gfid, s->qscale); | |
805 #endif | |
806 } | |
807 | |
783 if (s->pict_type == P_TYPE) { | 808 if (s->pict_type == P_TYPE) { |
784 if (get_bits1(&s->gb)) { | 809 if (get_bits1(&s->gb)) { |
785 /* skip mb */ | 810 /* skip mb */ |
786 s->mb_intra = 0; | 811 s->mb_intra = 0; |
787 for(i=0;i<6;i++) | 812 for(i=0;i<6;i++) |
792 s->mv[0][0][1] = 0; | 817 s->mv[0][0][1] = 0; |
793 s->mb_skiped = 1; | 818 s->mb_skiped = 1; |
794 return 0; | 819 return 0; |
795 } | 820 } |
796 cbpc = get_vlc(&s->gb, &inter_MCBPC_vlc); | 821 cbpc = get_vlc(&s->gb, &inter_MCBPC_vlc); |
822 //fprintf(stderr, "\tCBPC: %d", cbpc); | |
797 if (cbpc < 0) | 823 if (cbpc < 0) |
798 return -1; | 824 return -1; |
825 | |
799 dquant = cbpc & 8; | 826 dquant = cbpc & 8; |
800 s->mb_intra = ((cbpc & 4) != 0); | 827 s->mb_intra = ((cbpc & 4) != 0); |
801 } else { | 828 } else { |
802 cbpc = get_vlc(&s->gb, &intra_MCBPC_vlc); | 829 cbpc = get_vlc(&s->gb, &intra_MCBPC_vlc); |
803 if (cbpc < 0) | 830 if (cbpc < 0) |
864 mot_val[1] = my; | 891 mot_val[1] = my; |
865 } | 892 } |
866 } | 893 } |
867 } else { | 894 } else { |
868 s->ac_pred = 0; | 895 s->ac_pred = 0; |
869 if (s->h263_pred) { | 896 if (s->h263_pred) { |
870 s->ac_pred = get_bits1(&s->gb); | 897 s->ac_pred = get_bits1(&s->gb); |
871 } | 898 } |
872 cbpy = get_vlc(&s->gb, &cbpy_vlc); | 899 cbpy = get_vlc(&s->gb, &cbpy_vlc); |
873 cbp = (cbpc & 3) | (cbpy << 2); | 900 cbp = (cbpc & 3) | (cbpy << 2); |
874 if (dquant) { | 901 if (dquant) { |
1259 skip_bits(&s->gb, 8); | 1286 skip_bits(&s->gb, 8); |
1260 } | 1287 } |
1261 s->f_code = 1; | 1288 s->f_code = 1; |
1262 s->width = width; | 1289 s->width = width; |
1263 s->height = height; | 1290 s->height = height; |
1291 | |
1264 return 0; | 1292 return 0; |
1265 } | 1293 } |
1266 | 1294 |
1267 /* decode mpeg4 VOP header */ | 1295 /* decode mpeg4 VOP header */ |
1268 int mpeg4_decode_picture_header(MpegEncContext * s) | 1296 int mpeg4_decode_picture_header(MpegEncContext * s) |
1460 skip_bits(&s->gb, 8); | 1488 skip_bits(&s->gb, 8); |
1461 } | 1489 } |
1462 s->f_code = 1; | 1490 s->f_code = 1; |
1463 return 0; | 1491 return 0; |
1464 } | 1492 } |
1493 |