Mercurial > libavcodec.hg
comparison h263.c @ 880:1c32039e7215 libavcodec
aspect ratio cleanup
author | michaelni |
---|---|
date | Wed, 20 Nov 2002 13:08:04 +0000 |
parents | eacc2dd8fd9d |
children | 19f5b8b7c6d5 |
comparison
equal
deleted
inserted
replaced
879:af969e91f422 | 880:1c32039e7215 |
---|---|
116 else if (width == 1408 && height == 1152) | 116 else if (width == 1408 && height == 1152) |
117 format = 5; | 117 format = 5; |
118 else | 118 else |
119 format = 7; | 119 format = 7; |
120 return format; | 120 return format; |
121 } | |
122 | |
123 static void init_aspect_info(MpegEncContext * s){ | |
124 double aspect; | |
125 | |
126 emms_c(); //paranoia ;) | |
127 | |
128 if(s->avctx->aspect_ratio==0) aspect= 1.0; | |
129 aspect= s->avctx->aspect_ratio; | |
130 | |
131 ff_float2fraction(&s->aspected_width, &s->aspected_height, aspect, 255); | |
132 | |
133 if(s->aspected_width == 4 && s->aspected_height == 3) | |
134 s->aspect_ratio_info= FF_ASPECT_4_3_625; | |
135 else if(s->aspected_width == 16 && s->aspected_height == 9) | |
136 s->aspect_ratio_info= FF_ASPECT_16_9_625; | |
137 else if(s->aspected_width == 1 && s->aspected_height == 1) | |
138 s->aspect_ratio_info= FF_ASPECT_SQUARE; | |
139 else | |
140 s->aspect_ratio_info= FF_ASPECT_EXTENDED; | |
121 } | 141 } |
122 | 142 |
123 void h263_encode_picture_header(MpegEncContext * s, int picture_number) | 143 void h263_encode_picture_header(MpegEncContext * s, int picture_number) |
124 { | 144 { |
125 int format; | 145 int format; |
194 /* This should be here if PLUSPTYPE */ | 214 /* This should be here if PLUSPTYPE */ |
195 put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */ | 215 put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */ |
196 | 216 |
197 if (format == 7) { | 217 if (format == 7) { |
198 /* Custom Picture Format (CPFMT) */ | 218 /* Custom Picture Format (CPFMT) */ |
199 | 219 init_aspect_info(s); |
200 if (s->aspect_ratio_info) | 220 |
201 put_bits(&s->pb,4,s->aspect_ratio_info); | 221 put_bits(&s->pb,4,s->aspect_ratio_info); |
202 else | |
203 put_bits(&s->pb,4,2); /* Aspect ratio: CIF 12:11 (4:3) picture */ | |
204 put_bits(&s->pb,9,(s->width >> 2) - 1); | 222 put_bits(&s->pb,9,(s->width >> 2) - 1); |
205 put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */ | 223 put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */ |
206 put_bits(&s->pb,9,(s->height >> 2)); | 224 put_bits(&s->pb,9,(s->height >> 2)); |
207 if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) | 225 if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) |
208 { | 226 { |
1506 put_bits(&s->pb, 1, 0); /* random access vol */ | 1524 put_bits(&s->pb, 1, 0); /* random access vol */ |
1507 put_bits(&s->pb, 8, s->vo_type); /* video obj type indication */ | 1525 put_bits(&s->pb, 8, s->vo_type); /* video obj type indication */ |
1508 put_bits(&s->pb, 1, 1); /* is obj layer id= yes */ | 1526 put_bits(&s->pb, 1, 1); /* is obj layer id= yes */ |
1509 put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */ | 1527 put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */ |
1510 put_bits(&s->pb, 3, 1); /* is obj layer priority */ | 1528 put_bits(&s->pb, 3, 1); /* is obj layer priority */ |
1511 if(s->aspect_ratio_info) | 1529 |
1512 put_bits(&s->pb, 4, s->aspect_ratio_info);/* aspect ratio info */ | 1530 init_aspect_info(s); |
1513 else | 1531 |
1514 put_bits(&s->pb, 4, 1); /* aspect ratio info= sqare pixel */ | 1532 put_bits(&s->pb, 4, s->aspect_ratio_info);/* aspect ratio info */ |
1515 if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) | 1533 if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) |
1516 { | 1534 { |
1517 put_bits(&s->pb, 8, s->aspected_width); | 1535 put_bits(&s->pb, 8, s->aspected_width); |
1518 put_bits(&s->pb, 8, s->aspected_height); | 1536 put_bits(&s->pb, 8, s->aspected_height); |
1519 } | 1537 } |