# HG changeset patch # User michael # Date 1066681426 0 # Node ID dd544554ed42136b893078223b5290e7b0b92762 # Parent 0183874861fd3b609039012237dd46b587866123 AVRational sample_aspect_ratio aspect ratio in JPEG JFIF is SAR not DAR ! removed nonsense SAR guessing code various related cleanups bugs? diff -r 0183874861fd -r dd544554ed42 Makefile --- a/Makefile Mon Oct 20 10:33:13 2003 +0000 +++ b/Makefile Mon Oct 20 20:23:46 2003 +0000 @@ -18,7 +18,7 @@ fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \ vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o cljr.o \ roqvideo.o dpcm.o interplayvideo.o xan.o rpza.o cinepak.o msrle.o \ - msvideo1.o vqavideo.o idcinvideo.o adx.o + msvideo1.o vqavideo.o idcinvideo.o adx.o rational.o ifeq ($(AMR_NB),yes) ifeq ($(AMR_NB_FIXED),yes) diff -r 0183874861fd -r dd544554ed42 avcodec.h --- a/avcodec.h Mon Oct 20 10:33:13 2003 +0000 +++ b/avcodec.h Mon Oct 20 20:23:46 2003 +0000 @@ -12,10 +12,11 @@ #endif #include "common.h" +#include "rational.h" #define FFMPEG_VERSION_INT 0x000408 #define FFMPEG_VERSION "0.4.8" -#define LIBAVCODEC_BUILD 4686 +#define LIBAVCODEC_BUILD 4687 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -1034,11 +1035,11 @@ #define FF_PRED_MEDIAN 2 /** - * aspect ratio (0 if unknown). + * sample aspect ratio (0 if unknown). * - encoding: set by user. * - decoding: set by lavc. */ - float aspect_ratio; + AVRational sample_aspect_ratio; /** * the picture in the bitstream. diff -r 0183874861fd -r dd544554ed42 common.c --- a/common.c Mon Oct 20 10:33:13 2003 +0000 +++ b/common.c Mon Oct 20 20:23:46 2003 +0000 @@ -386,29 +386,3 @@ if(b) return ff_gcd(b, a%b); else return a; } - -void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max){ - double best_diff=1E10, diff; - int best_denom=1, best_nom=1; - int nom, denom, gcd; - - //brute force here, perhaps we should try continued fractions if we need large max ... - for(denom=1; denom<=max; denom++){ - nom= (int)(f*denom + 0.5); - if(nom<=0 || nom>max) continue; - - diff= ABS( f - (double)nom / (double)denom ); - if(diff < best_diff){ - best_diff= diff; - best_nom= nom; - best_denom= denom; - } - } - - gcd= ff_gcd(best_nom, best_denom); - best_nom /= gcd; - best_denom /= gcd; - - *nom_arg= best_nom; - *denom_arg= best_denom; -} diff -r 0183874861fd -r dd544554ed42 common.h --- a/common.h Mon Oct 20 10:33:13 2003 +0000 +++ b/common.h Mon Oct 20 20:23:46 2003 +0000 @@ -1056,9 +1056,6 @@ #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) -void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max); - - #ifdef ARCH_X86 #define MASK_ABS(mask, level)\ asm volatile(\ diff -r 0183874861fd -r dd544554ed42 h263.c --- a/h263.c Mon Oct 20 10:33:13 2003 +0000 +++ b/h263.c Mon Oct 20 20:23:46 2003 +0000 @@ -131,19 +131,13 @@ #ifdef CONFIG_ENCODERS -static void float_aspect_to_info(MpegEncContext * s, float aspect){ +static void aspect_to_info(MpegEncContext * s, AVRational 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); + if(aspect.num==0) aspect= (AVRational){1,1}; + for(i=1; i<6; i++){ - if(s->aspected_width == pixel_aspect[i][0] && s->aspected_height== pixel_aspect[i][1]){ + if(av_cmp_q(pixel_aspect[i], aspect) == 0){ s->aspect_ratio_info=i; return; } @@ -270,16 +264,15 @@ if (format == 7) { /* Custom Picture Format (CPFMT) */ - float_aspect_to_info(s, s->avctx->aspect_ratio); + aspect_to_info(s, s->avctx->sample_aspect_ratio); put_bits(&s->pb,4,s->aspect_ratio_info); put_bits(&s->pb,9,(s->width >> 2) - 1); put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */ put_bits(&s->pb,9,(s->height >> 2)); - if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) - { - put_bits(&s->pb, 8, s->aspected_width); - put_bits(&s->pb, 8, s->aspected_height); + if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){ + put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num); + put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den); } } @@ -1949,13 +1942,12 @@ put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */ put_bits(&s->pb, 3, 1); /* is obj layer priority */ - float_aspect_to_info(s, s->avctx->aspect_ratio); + aspect_to_info(s, s->avctx->sample_aspect_ratio); put_bits(&s->pb, 4, s->aspect_ratio_info);/* aspect ratio info */ - if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) - { - put_bits(&s->pb, 8, s->aspected_width); - put_bits(&s->pb, 8, s->aspected_height); + if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){ + put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num); + put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den); } if(s->low_delay){ @@ -4341,11 +4333,10 @@ dprintf("\nH.263+ Custom picture: %dx%d\n",width,height); if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) { /* aspected dimensions */ - s->aspected_width = get_bits(&s->gb, 8); - s->aspected_height = get_bits(&s->gb, 8); + s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8); + s->avctx->sample_aspect_ratio.den= 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]; + s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info]; } } else { width = h263_format[format][0]; @@ -4632,11 +4623,10 @@ //printf("vo type:%d\n",s->vo_type); s->aspect_ratio_info= get_bits(gb, 4); 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 + s->avctx->sample_aspect_ratio.num= get_bits(gb, 8); // par_width + s->avctx->sample_aspect_ratio.den= 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]; + s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info]; } if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */ diff -r 0183874861fd -r dd544554ed42 h263dec.c --- a/h263dec.c Mon Oct 20 10:33:13 2003 +0000 +++ b/h263dec.c Mon Oct 20 20:23:46 2003 +0000 @@ -393,7 +393,6 @@ MpegEncContext *s = avctx->priv_data; int ret; AVFrame *pict = data; - float new_aspect; #ifdef PRINT_FRAME_TIME uint64_t time= rdtsc(); @@ -602,13 +601,8 @@ /* and other parameters. So then we could init the picture */ /* FIXME: By the way H263 decoder is evolving it should have */ /* an H263EncContext */ - if(s->aspected_height) - new_aspect= s->aspected_width*s->width / (float)(s->height*s->aspected_height); - else - new_aspect=0; - if ( s->width != avctx->width || s->height != avctx->height - || ABS(new_aspect - avctx->aspect_ratio) > 0.001) { + if ( s->width != avctx->width || s->height != avctx->height) { /* H.263 could change picture size any time */ ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat s->parse_context.buffer=0; @@ -618,7 +612,6 @@ if (!s->context_initialized) { avctx->width = s->width; avctx->height = s->height; - avctx->aspect_ratio= new_aspect; goto retry; } diff -r 0183874861fd -r dd544554ed42 h264.c --- a/h264.c Mon Oct 20 10:33:13 2003 +0000 +++ b/h264.c Mon Oct 20 20:23:46 2003 +0000 @@ -79,8 +79,7 @@ int crop_top; ///< frame_cropping_rect_top_offset int crop_bottom; ///< frame_cropping_rect_bottom_offset int vui_parameters_present_flag; - int sar_width; - int sar_height; + AVRational sar; short offset_for_ref_frame[256]; //FIXME dyn aloc? }SPS; @@ -2829,7 +2828,6 @@ int first_mb_in_slice, pps_id; int num_ref_idx_active_override_flag; static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE}; - float new_aspect; s->current_picture.reference= h->nal_ref_idc != 0; @@ -2881,14 +2879,8 @@ else s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom); //FIXME recheck - if(s->aspected_height) //FIXME emms at end of slice ? - new_aspect= h->sps.sar_width*s->width / (float)(s->height*h->sps.sar_height); - else - new_aspect=0; - if (s->context_initialized - && ( s->width != s->avctx->width || s->height != s->avctx->height - || ABS(new_aspect - s->avctx->aspect_ratio) > 0.001)) { + && ( s->width != s->avctx->width || s->height != s->avctx->height)) { free_tables(h); MPV_common_end(s); } @@ -2900,7 +2892,7 @@ s->avctx->width = s->width; s->avctx->height = s->height; - s->avctx->aspect_ratio= new_aspect; + s->avctx->sample_aspect_ratio= h->sps.sar; } if(first_mb_in_slice == 0){ @@ -3736,18 +3728,17 @@ if( aspect_ratio_info_present_flag ) { aspect_ratio_idc= get_bits(&s->gb, 8); if( aspect_ratio_idc == EXTENDED_SAR ) { - sps->sar_width= get_bits(&s->gb, 16); - sps->sar_height= get_bits(&s->gb, 16); + sps->sar.num= get_bits(&s->gb, 16); + sps->sar.den= get_bits(&s->gb, 16); }else if(aspect_ratio_idc < 16){ - sps->sar_width= pixel_aspect[aspect_ratio_idc][0]; - sps->sar_height= pixel_aspect[aspect_ratio_idc][1]; + sps->sar= pixel_aspect[aspect_ratio_idc]; }else{ fprintf(stderr, "illegal aspect ratio\n"); return -1; } }else{ - sps->sar_width= - sps->sar_height= 0; + sps->sar.num= + sps->sar.den= 0; } // s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height); #if 0 diff -r 0183874861fd -r dd544554ed42 h264data.h --- a/h264data.h Mon Oct 20 10:33:13 2003 +0000 +++ b/h264data.h Mon Oct 20 20:23:46 2003 +0000 @@ -51,8 +51,8 @@ #define EXTENDED_SAR 255 -static const uint16_t pixel_aspect[16][2]={ - {0, 0}, +static const AVRational pixel_aspect[14]={ + {0, 1}, {1, 1}, {12, 11}, {10, 11}, diff -r 0183874861fd -r dd544554ed42 mjpeg.c --- a/mjpeg.c Mon Oct 20 10:33:13 2003 +0000 +++ b/mjpeg.c Mon Oct 20 20:23:46 2003 +0000 @@ -381,28 +381,8 @@ put_string(p, "JFIF"); /* this puts the trailing zero-byte too */ put_bits(p, 16, 0x0201); /* v 1.02 */ put_bits(p, 8, 0); /* units type: 0 - aspect ratio */ - switch(s->aspect_ratio_info) - { - case FF_ASPECT_4_3_625: - case FF_ASPECT_4_3_525: - put_bits(p, 16, 4); - put_bits(p, 16, 3); - break; - case FF_ASPECT_16_9_625: - case FF_ASPECT_16_9_525: - put_bits(p, 16, 16); - put_bits(p, 16, 9); - break; - case FF_ASPECT_EXTENDED: - put_bits(p, 16, s->aspected_width); - put_bits(p, 16, s->aspected_height); - break; - case FF_ASPECT_SQUARE: - default: - put_bits(p, 16, 1); /* aspect: 1:1 */ - put_bits(p, 16, 1); - break; - } + put_bits(p, 16, s->avctx->sample_aspect_ratio.num); + put_bits(p, 16, s->avctx->sample_aspect_ratio.den); put_bits(p, 8, 0); /* thumbnail width */ put_bits(p, 8, 0); /* thumbnail height */ } @@ -1547,29 +1527,10 @@ skip_bits(&s->gb, 8); /* the trailing zero-byte */ printf("mjpeg: JFIF header found (version: %x.%x)\n", get_bits(&s->gb, 8), get_bits(&s->gb, 8)); - if (get_bits(&s->gb, 8) == 0) - { - int x_density, y_density; - x_density = get_bits(&s->gb, 16); - y_density = get_bits(&s->gb, 16); + skip_bits(&s->gb, 8); - dprintf("x/y density: %d (%f), %d (%f)\n", x_density, - (float)x_density, y_density, (float)y_density); -#if 0 - //MN: needs to be checked - if(x_density) -// s->avctx->aspect_ratio= s->width*y_density/((float)s->height*x_density); - s->avctx->aspect_ratio = (float)x_density/y_density; - /* it's better, but every JFIF I have seen stores 1:1 */ - else - s->avctx->aspect_ratio= 0.0; -#endif - } - else - { - skip_bits(&s->gb, 16); - skip_bits(&s->gb, 16); - } + s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 16); + s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 16); t_w = get_bits(&s->gb, 8); t_h = get_bits(&s->gb, 8); @@ -2085,7 +2046,7 @@ memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos)); j += sizeof(sp5x_data_sos); - for (i = 14; i < buf_size, j < buf_size+1024-2; i++) + for (i = 14; i < buf_size && j < buf_size+1024-2; i++) { recoded[j++] = buf[i]; if (buf[i] == 0xff) diff -r 0183874861fd -r dd544554ed42 mpeg12.c --- a/mpeg12.c Mon Oct 20 10:33:13 2003 +0000 +++ b/mpeg12.c Mon Oct 20 20:23:46 2003 +0000 @@ -190,10 +190,10 @@ int n, i; uint64_t time_code; float best_aspect_error= 1E10; - float aspect_ratio= s->avctx->aspect_ratio; + float aspect_ratio= av_q2d(s->avctx->sample_aspect_ratio); int constraint_parameter_flag; - if(aspect_ratio==0.0) aspect_ratio= s->width / (float)s->height; //pixel aspect 1:1 (VGA) + if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA) if (s->current_picture.key_frame) { /* mpeg1 header repeated every gop */ @@ -219,7 +219,7 @@ put_bits(&s->pb, 12, s->height); for(i=1; i<15; i++){ - float error= mpeg1_aspect[i] - s->width/(s->height*aspect_ratio); + float error= mpeg1_aspect[i] - aspect_ratio; error= ABS(error); if(error < best_aspect_error){ @@ -1742,7 +1742,6 @@ int bit_rate_ext, vbv_buf_ext; int frame_rate_ext_n, frame_rate_ext_d; int level, profile; - float aspect; skip_bits(&s->gb, 1); /* profil and level esc*/ profile= get_bits(&s->gb, 3); @@ -1774,9 +1773,15 @@ s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO; s->avctx->sub_id = 2; /* indicates mpeg2 found */ - aspect= mpeg2_aspect[s->aspect_ratio_info]; - if(aspect>0.0) s->avctx->aspect_ratio= s->width/(aspect*s->height); - else if(aspect<0.0) s->avctx->aspect_ratio= -1.0/aspect; + if(s->aspect_ratio_info <= 1) + s->avctx->sample_aspect_ratio= mpeg2_aspect[s->aspect_ratio_info]; + else{ + s->avctx->sample_aspect_ratio= + av_div_q( + mpeg2_aspect[s->aspect_ratio_info], + (AVRational){s->width, s->height} + ); + } if(s->avctx->debug & FF_DEBUG_PICT_INFO) printf("profile: %d, level: %d \n", profile, level); @@ -1802,8 +1807,12 @@ s1->pan_scan.width= 16*w; s1->pan_scan.height=16*h; - if(mpeg2_aspect[s->aspect_ratio_info] < 0.0) - s->avctx->aspect_ratio*= (s->width * h)/(float)(s->height * w); + if(s->aspect_ratio_info > 1) + s->avctx->sample_aspect_ratio= + av_div_q( + mpeg2_aspect[s->aspect_ratio_info], + (AVRational){w, h} + ); if(s->avctx->debug & FF_DEBUG_PICT_INFO) printf("sde w:%d, h:%d\n", w, h); @@ -2243,7 +2252,7 @@ s->aspect_ratio_info= get_bits(&s->gb, 4); if(s->codec_id == CODEC_ID_MPEG1VIDEO){ aspect= mpeg1_aspect[s->aspect_ratio_info]; - if(aspect!=0.0) avctx->aspect_ratio= width/(aspect*height); + if(aspect!=0.0) avctx->sample_aspect_ratio= av_d2q(aspect, 30000); } s->frame_rate_index = get_bits(&s->gb, 4); diff -r 0183874861fd -r dd544554ed42 mpeg12data.h --- a/mpeg12data.h Mon Oct 20 10:33:13 2003 +0000 +++ b/mpeg12data.h Mon Oct 20 20:23:46 2003 +0000 @@ -416,11 +416,22 @@ 1.2015, }; -static const float mpeg2_aspect[16]={ - 0, - 1.0, - -3.0/4.0, - -9.0/16.0, - -1.0/2.21, +static const AVRational mpeg2_aspect[16]={ + {0,1}, + {1,1}, + {4,3}, + {16,9}, + {221,100}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, + {0,1}, }; diff -r 0183874861fd -r dd544554ed42 mpeg4data.h --- a/mpeg4data.h Mon Oct 20 10:33:13 2003 +0000 +++ b/mpeg4data.h Mon Oct 20 20:23:46 2003 +0000 @@ -341,23 +341,23 @@ {1, 1}, {1, 2}, {1, 3}, {1, 4}, }; -static const uint16_t pixel_aspect[16][2]={ - {0, 0}, +static const AVRational pixel_aspect[16]={ + {0, 1}, {1, 1}, {12, 11}, {10, 11}, {16, 11}, {40, 33}, - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0}, - {0, 0}, + {0, 1}, + {0, 1}, + {0, 1}, + {0, 1}, + {0, 1}, + {0, 1}, + {0, 1}, + {0, 1}, + {0, 1}, + {0, 1}, }; /* these matrixes will be permuted for the idct */ diff -r 0183874861fd -r dd544554ed42 mpegvideo.h --- a/mpegvideo.h Mon Oct 20 10:33:13 2003 +0000 +++ b/mpegvideo.h Mon Oct 20 20:23:46 2003 +0000 @@ -554,8 +554,6 @@ int new_pred; int reduced_res_vop; int aspect_ratio_info; //FIXME remove - int aspected_width; //FIXME remove - int aspected_height; //FIXME remove int sprite_warping_accuracy; int low_latency_sprite; int data_partitioning; ///< data partitioning flag from header diff -r 0183874861fd -r dd544554ed42 rational.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rational.c Mon Oct 20 20:23:46 2003 +0000 @@ -0,0 +1,61 @@ +/* + * Rational numbers + * Copyright (c) 2003 Michael Niedermayer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/** + * @file rational.c + * Rational numbers + * @author Michael Niedermayer + */ + +//#include +#include + +#include "common.h" +#include "avcodec.h" +#include "rational.h" + +AVRational av_mul_q(AVRational b, AVRational c){ + av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX); + return b; +} + +AVRational av_div_q(AVRational b, AVRational c){ + av_reduce(&b.num, &b.den, b.num * (int64_t)c.den, b.den * (int64_t)c.num, INT_MAX); + return b; +} + +AVRational av_add_q(AVRational b, AVRational c){ + av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX); + return b; +} + +AVRational av_sub_q(AVRational b, AVRational c){ + av_reduce(&b.num, &b.den, b.num * (int64_t)c.den - c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX); + return b; +} + +AVRational av_d2q(double d, int max){ + AVRational a; + int exponent= FFMAX( (int)log2(ABS(d) + 1e-20), 0); + int64_t den= 1LL << (61 - exponent); + av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max); + + return a; +} diff -r 0183874861fd -r dd544554ed42 rational.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rational.h Mon Oct 20 20:23:46 2003 +0000 @@ -0,0 +1,53 @@ +/* + * Rational numbers + * Copyright (c) 2003 Michael Niedermayer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/** + * @file rational.h + * Rational numbers. + * @author Michael Niedermayer + */ + +#ifndef RATIONAL_H +#define RATIONAL_H + +typedef struct AVRational{ + int num; + int den; +} AVRational; + +static inline int av_cmp_q(AVRational a, AVRational b){ + const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den; + + if (tmp < 0) return -1; + else if(tmp == 0) return 0; + else return 1; +} + +static inline double av_q2d(AVRational a){ + return a.num / (double) a.den; +} + +AVRational av_mul_q(AVRational b, AVRational c); +AVRational av_div_q(AVRational b, AVRational c); +AVRational av_add_q(AVRational b, AVRational c); +AVRational av_sub_q(AVRational b, AVRational c); +AVRational av_d2q(double d, int max); + +#endif // RATIONAL_H diff -r 0183874861fd -r dd544554ed42 utils.c --- a/utils.c Mon Oct 20 10:33:13 2003 +0000 +++ b/utils.c Mon Oct 20 20:23:46 2003 +0000 @@ -314,6 +314,7 @@ s->me_subpel_quality=8; s->lmin= FF_QP2LAMBDA * s->qmin; s->lmax= FF_QP2LAMBDA * s->qmax; + s->sample_aspect_ratio= (AVRational){0,1}; s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS; s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;