comparison h263.c @ 1865:92e94c550def libavcodec

h263 framerate & aspect ratio fixes
author michael
date Sat, 06 Mar 2004 12:33:56 +0000
parents cd2d7fcfab7a
children c13d3543c73a
comparison
equal deleted inserted replaced
1864:9a73e6dc5d68 1865:92e94c550def
202 align_put_bits(&s->pb); 202 align_put_bits(&s->pb);
203 203
204 /* Update the pointer to last GOB */ 204 /* Update the pointer to last GOB */
205 s->ptr_lastgob = pbBufPtr(&s->pb); 205 s->ptr_lastgob = pbBufPtr(&s->pb);
206 put_bits(&s->pb, 22, 0x20); /* PSC */ 206 put_bits(&s->pb, 22, 0x20); /* PSC */
207 put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->frame_rate_base) / 207 put_bits(&s->pb, 8, ((s->picture_number * 30000LL * s->avctx->frame_rate_base) /
208 s->avctx->frame_rate) & 0xff); 208 (1001LL *s->avctx->frame_rate)) & 0xff); /* TemporalReference */
209 209
210 put_bits(&s->pb, 1, 1); /* marker */ 210 put_bits(&s->pb, 1, 1); /* marker */
211 put_bits(&s->pb, 1, 0); /* h263 id */ 211 put_bits(&s->pb, 1, 0); /* h263 id */
212 put_bits(&s->pb, 1, 0); /* split screen off */ 212 put_bits(&s->pb, 1, 0); /* split screen off */
213 put_bits(&s->pb, 1, 0); /* camera off */ 213 put_bits(&s->pb, 1, 0); /* camera off */
4889 if (startcode != 0x20) { 4889 if (startcode != 0x20) {
4890 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); 4890 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
4891 return -1; 4891 return -1;
4892 } 4892 }
4893 /* temporal reference */ 4893 /* temporal reference */
4894 s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */ 4894 i = get_bits(&s->gb, 8); /* picture timestamp */
4895 if( (s->picture_number&~0xFF)+i < s->picture_number)
4896 i+= 256;
4897 s->picture_number= (s->picture_number&~0xFF) + i;
4895 4898
4896 /* PTYPE starts here */ 4899 /* PTYPE starts here */
4897 if (get_bits1(&s->gb) != 1) { 4900 if (get_bits1(&s->gb) != 1) {
4898 /* marker */ 4901 /* marker */
4899 av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n"); 4902 av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
4941 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); 4944 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
4942 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ 4945 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
4943 4946
4944 s->width = width; 4947 s->width = width;
4945 s->height = height; 4948 s->height = height;
4949 s->avctx->sample_aspect_ratio= (AVRational){12,11};
4950 s->avctx->frame_rate = 30000;
4951 s->avctx->frame_rate_base= 1001;
4946 } else { 4952 } else {
4947 int ufep; 4953 int ufep;
4948 4954
4949 /* H.263v2 */ 4955 /* H.263v2 */
4950 s->h263_plus = 1; 4956 s->h263_plus = 1;
4953 /* ufep other than 0 and 1 are reserved */ 4959 /* ufep other than 0 and 1 are reserved */
4954 if (ufep == 1) { 4960 if (ufep == 1) {
4955 /* OPPTYPE */ 4961 /* OPPTYPE */
4956 format = get_bits(&s->gb, 3); 4962 format = get_bits(&s->gb, 3);
4957 dprintf("ufep=1, format: %d\n", format); 4963 dprintf("ufep=1, format: %d\n", format);
4958 skip_bits(&s->gb,1); /* Custom PCF */ 4964 if (get_bits1(&s->gb) != 0) {
4965 av_log(s->avctx, AV_LOG_ERROR, "Custom PCF not supported\n");
4966 }
4959 s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */ 4967 s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
4960 if (get_bits1(&s->gb) != 0) { 4968 if (get_bits1(&s->gb) != 0) {
4961 av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); 4969 av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
4962 } 4970 }
4963 s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */ 4971 s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
5026 s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info]; 5034 s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
5027 } 5035 }
5028 } else { 5036 } else {
5029 width = h263_format[format][0]; 5037 width = h263_format[format][0];
5030 height = h263_format[format][1]; 5038 height = h263_format[format][1];
5039 s->avctx->sample_aspect_ratio= (AVRational){12,11};
5031 } 5040 }
5032 if ((width == 0) || (height == 0)) 5041 if ((width == 0) || (height == 0))
5033 return -1; 5042 return -1;
5043 s->avctx->frame_rate = 30000;
5044 s->avctx->frame_rate_base= 1001;
5034 s->width = width; 5045 s->width = width;
5035 s->height = height; 5046 s->height = height;
5036 if (s->umvplus) { 5047 if (s->umvplus) {
5037 if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */ 5048 if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
5038 skip_bits1(&s->gb); 5049 skip_bits1(&s->gb);