~siretart/xine-lib/ubuntu

« back to all changes in this revision

Viewing changes to src/libffmpeg/libavutil/rational.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-12-15 13:13:45 UTC
  • mfrom: (0.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051215131345-8n4osv1j7fy9c1s1
* SECURITY UPDATE: Fix arbitrary code execution with crafted PNG images in
  embedded ffmpeg copy.
* src/libffmpeg/libavcodec/utils.c, avcodec_default_get_buffer(): Apply
  upstream patch to fix buffer overflow on decoding of small PIX_FMT_PAL8
  PNG files.
* References:
  CVE-2005-4048
  http://mplayerhq.hu/pipermail/ffmpeg-devel/2005-November/005333.html
  http://www1.mplayerhq.hu/cgi-bin/cvsweb.cgi/ffmpeg/libavcodec/
  utils.c.diff?r1=1.161&r2=1.162&cvsroot=FFMpeg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Rational numbers
 
3
 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
/**
 
22
 * @file rational.h
 
23
 * Rational numbers.
 
24
 * @author Michael Niedermayer <michaelni@gmx.at>
 
25
 */
 
26
 
 
27
#ifndef RATIONAL_H
 
28
#define RATIONAL_H
 
29
 
 
30
/**
 
31
 * Rational number num/den.
 
32
 */
 
33
typedef struct AVRational{
 
34
    int num; ///< numerator
 
35
    int den; ///< denominator
 
36
} AVRational;
 
37
 
 
38
/**
 
39
 * returns 0 if a==b, 1 if a>b and -1 if a<b.
 
40
 */
 
41
static inline int av_cmp_q(AVRational a, AVRational b){
 
42
    const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
 
43
 
 
44
    if(tmp) return (tmp>>63)|1;
 
45
    else    return 0;
 
46
}
 
47
 
 
48
/**
 
49
 * converts the given AVRational to a double.
 
50
 */
 
51
static inline double av_q2d(AVRational a){
 
52
    return a.num / (double) a.den;
 
53
}
 
54
 
 
55
/**
 
56
 * reduce a fraction.
 
57
 * this is usefull for framerate calculations
 
58
 * @param max the maximum allowed for dst_nom & dst_den
 
59
 * @return 1 if exact, 0 otherwise
 
60
 */
 
61
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
 
62
 
 
63
AVRational av_mul_q(AVRational b, AVRational c);
 
64
AVRational av_div_q(AVRational b, AVRational c);
 
65
AVRational av_add_q(AVRational b, AVRational c);
 
66
AVRational av_sub_q(AVRational b, AVRational c);
 
67
AVRational av_d2q(double d, int max);
 
68
 
 
69
#endif // RATIONAL_H