aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h263.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2002-11-25 09:23:19 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-11-25 09:23:19 +0000
commit58b0b0dd9337fb93d777965cdd3ec08f6db3fea6 (patch)
tree7eabe09a67f19e5b69a45590de5771b216cb908c /libavcodec/h263.c
parentc9f99fef4fbbcaf7bb99bc0a3e9603e781e163ca (diff)
downloadffmpeg-58b0b0dd9337fb93d777965cdd3ec08f6db3fea6.tar.gz
fixing aspect
Originally committed as revision 1273 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h263.c')
-rw-r--r--libavcodec/h263.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index 8bb23eac5f..08ad2c293e 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -120,24 +120,25 @@ int h263_get_picture_format(int width, int height)
return format;
}
-static void init_aspect_info(MpegEncContext * s){
- double aspect;
-
- emms_c(); //paranoia ;)
-
- if(s->avctx->aspect_ratio==0) aspect= 1.0;
- aspect= s->avctx->aspect_ratio;
+static void float_aspect_to_info(MpegEncContext * s, float aspect){
+ int i;
+
+ aspect*= s->height/(double)s->width;
+//printf("%f\n", aspect);
+ if(aspect==0) aspect= 1.0;
+
ff_float2fraction(&s->aspected_width, &s->aspected_height, aspect, 255);
+
+//printf("%d %d\n", s->aspected_width, s->aspected_height);
+ for(i=1; i<6; i++){
+ if(s->aspected_width == pixel_aspect[i][0] && s->aspected_height== pixel_aspect[i][1]){
+ s->aspect_ratio_info=i;
+ return;
+ }
+ }
- if(s->aspected_width == 4 && s->aspected_height == 3)
- s->aspect_ratio_info= FF_ASPECT_4_3_625;
- else if(s->aspected_width == 16 && s->aspected_height == 9)
- s->aspect_ratio_info= FF_ASPECT_16_9_625;
- else if(s->aspected_width == 1 && s->aspected_height == 1)
- s->aspect_ratio_info= FF_ASPECT_SQUARE;
- else
- s->aspect_ratio_info= FF_ASPECT_EXTENDED;
+ s->aspect_ratio_info= FF_ASPECT_EXTENDED;
}
void h263_encode_picture_header(MpegEncContext * s, int picture_number)
@@ -216,7 +217,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number)
if (format == 7) {
/* Custom Picture Format (CPFMT) */
- init_aspect_info(s);
+ float_aspect_to_info(s, s->avctx->aspect_ratio);
put_bits(&s->pb,4,s->aspect_ratio_info);
put_bits(&s->pb,9,(s->width >> 2) - 1);
@@ -1527,7 +1528,7 @@ static void mpeg4_encode_vol_header(MpegEncContext * s)
put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */
put_bits(&s->pb, 3, 1); /* is obj layer priority */
- init_aspect_info(s);
+ float_aspect_to_info(s, s->avctx->aspect_ratio);
put_bits(&s->pb, 4, s->aspect_ratio_info);/* aspect ratio info */
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED)
@@ -3833,6 +3834,9 @@ int h263_decode_picture_header(MpegEncContext *s)
/* aspected dimensions */
s->aspected_width = get_bits(&s->gb, 8);
s->aspected_height = get_bits(&s->gb, 8);
+ }else{
+ s->aspected_width = pixel_aspect[s->aspect_ratio_info][0];
+ s->aspected_height= pixel_aspect[s->aspect_ratio_info][1];
}
} else {
width = h263_format[format][0];
@@ -4098,6 +4102,9 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
if(s->aspect_ratio_info == FF_ASPECT_EXTENDED){
s->aspected_width = get_bits(gb, 8); // par_width
s->aspected_height = get_bits(gb, 8); // par_height
+ }else{
+ s->aspected_width = pixel_aspect[s->aspect_ratio_info][0];
+ s->aspected_height= pixel_aspect[s->aspect_ratio_info][1];
}
if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */