annotate src/ffmpeg/libavcodec/utils.c @ 830:68562d99230f trunk

[svn] - more symbol cleanups.
author nenolod
date Mon, 12 Mar 2007 15:23:10 -0700
parents a53d893eb303
children dec0488e1344
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1 /*
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
2 * utils for libavcodec
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard.
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
4 * Copyright (c) 2003 Michel Bardiaux for the av_log API
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
5 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
6 * Copyright (c) 2004 Roman Bogorodskiy (bmp-wma specific stuff)
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
7 *
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
8 * This library is free software; you can redistribute it and/or
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
11 * version 2 of the License, or (at your option) any later version.
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
12 *
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
13 * This library is distributed in the hope that it will be useful,
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
16 * Lesser General Public License for more details.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
17 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
19 * License along with this library; if not, write to the Free Software
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
21 */
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
22
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
23 #include "avcodec.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
24 #include "dsputil.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
25 #include <stdarg.h>
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
26
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
27 /* encoder management */
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
28 AVCodec *first_avcodec;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
29
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
30 void register_avcodec(AVCodec *format)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
31 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
32 AVCodec **p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
33 p = &first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
34 while (*p != NULL) p = &(*p)->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
35 *p = format;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
36 format->next = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
37 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
38
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
39 typedef struct InternalBuffer{
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
40 int last_pic_num;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
41 uint8_t *base[4];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
42 uint8_t *data[4];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
43 int linesize[4];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
44 }InternalBuffer;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
45
818
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
46 const uint8_t ff_reverse[256]={
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
47 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
48 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
49 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
50 0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
51 0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
52 0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
53 0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
54 0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
55 0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
56 0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
57 0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
58 0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
59 0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
60 0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
61 0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
62 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
63 };
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
64
820
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
65 int av_get_bits_per_sample(enum CodecID codec_id){
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
66 switch(codec_id){
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
67 case CODEC_ID_ADPCM_SBPRO_2:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
68 return 2;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
69 case CODEC_ID_ADPCM_SBPRO_3:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
70 return 3;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
71 case CODEC_ID_ADPCM_SBPRO_4:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
72 case CODEC_ID_ADPCM_CT:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
73 return 4;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
74 case CODEC_ID_PCM_ALAW:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
75 case CODEC_ID_PCM_MULAW:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
76 case CODEC_ID_PCM_S8:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
77 case CODEC_ID_PCM_U8:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
78 return 8;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
79 case CODEC_ID_PCM_S16BE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
80 case CODEC_ID_PCM_S16LE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
81 case CODEC_ID_PCM_U16BE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
82 case CODEC_ID_PCM_U16LE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
83 return 16;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
84 case CODEC_ID_PCM_S24DAUD:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
85 case CODEC_ID_PCM_S24BE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
86 case CODEC_ID_PCM_S24LE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
87 case CODEC_ID_PCM_U24BE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
88 case CODEC_ID_PCM_U24LE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
89 return 24;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
90 case CODEC_ID_PCM_S32BE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
91 case CODEC_ID_PCM_S32LE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
92 case CODEC_ID_PCM_U32BE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
93 case CODEC_ID_PCM_U32LE:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
94 return 32;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
95 default:
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
96 return 0;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
97 }
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
98 }
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
99
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
100 /**
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
101 * decode a frame.
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
102 * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
103 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
104 * @param buf_size the size of the buffer in bytes
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
105 * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
106 * @return -1 if error, otherwise return the number of
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
107 * bytes used.
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
108 */
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
109 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
110 int *got_picture_ptr,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
111 uint8_t *buf, int buf_size)
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
112 {
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
113 int ret;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
114
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
115 *got_picture_ptr= 0;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
116 if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
117 return -1;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
118 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
119 ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
120 buf, buf_size);
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
121
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
122 emms_c(); //needed to avoid an emms_c() call before every return;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
123
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
124 if (*got_picture_ptr)
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
125 avctx->frame_number++;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
126 }else
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
127 ret= 0;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
128
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
129 return ret;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
130 }
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
131
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
132 /* decode an audio frame. return -1 if error, otherwise return the
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
133 *number of bytes used. If no frame could be decompressed,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
134 *frame_size_ptr is zero. Otherwise, it is the decompressed frame
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
135 *size in BYTES. */
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
136 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
137 int *frame_size_ptr,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
138 uint8_t *buf, int buf_size)
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
139 {
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
140 int ret;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
141
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
142 *frame_size_ptr= 0;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
143 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
144 ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
145 buf, buf_size);
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
146 avctx->frame_number++;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
147 }else
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
148 ret= 0;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
149 return ret;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
150 }
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
151
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
152 /* decode a subtitle message. return -1 if error, otherwise return the
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
153 *number of bytes used. If no subtitle could be decompressed,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
154 *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
155 int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
156 int *got_sub_ptr,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
157 const uint8_t *buf, int buf_size)
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
158 {
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
159 int ret;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
160
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
161 *got_sub_ptr = 0;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
162 ret = avctx->codec->decode(avctx, sub, got_sub_ptr,
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
163 (uint8_t *)buf, buf_size);
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
164 if (*got_sub_ptr)
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
165 avctx->frame_number++;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
166 return ret;
a53d893eb303 [svn] - remove more video codecs
nenolod
parents: 818
diff changeset
167 }
818
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
168
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
169 #define INTERNAL_BUFFER_SIZE 32
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
170
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
171 #undef ALIGN
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
172 #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
173
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
174 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
175 int w_align= 1;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
176 int h_align= 1;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
177
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
178 switch(s->pix_fmt){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
179 case PIX_FMT_YUV420P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
180 case PIX_FMT_YUV422:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
181 case PIX_FMT_YUV422P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
182 case PIX_FMT_YUV444P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
183 case PIX_FMT_GRAY8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
184 case PIX_FMT_YUVJ420P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
185 case PIX_FMT_YUVJ422P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
186 case PIX_FMT_YUVJ444P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
187 w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
188 h_align= 16;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
189 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
190 case PIX_FMT_YUV411P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
191 w_align=32;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
192 h_align=8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
193 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
194 case PIX_FMT_YUV410P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
195 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
196 w_align= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
197 h_align= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
198 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
199 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
200
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
201 *width = ALIGN(*width , w_align);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
202 *height= ALIGN(*height, h_align);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
203 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
204
818
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
205 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt){
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
206 return fmt[0];
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
207 }
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
208
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
209 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
210 int i;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
211 InternalBuffer *buf, *last, temp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
212
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
213 assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
214 assert(s->internal_buffer_count);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
215
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
216 buf = NULL; /* avoids warning */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
217 for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
218 buf= &((InternalBuffer*)s->internal_buffer)[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
219 if(buf->data[0] == pic->data[0])
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
220 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
221 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
222 assert(i < s->internal_buffer_count);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
223 s->internal_buffer_count--;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
224 last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
225
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
226 temp= *buf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
227 *buf= *last;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
228 *last= temp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
229
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
230 for(i=0; i<3; i++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
231 pic->data[i]=NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
232 // pic->base[i]=NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
233 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
234 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
235
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
236
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
237 void avcodec_get_context_defaults(AVCodecContext *s){
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
238 s->bit_rate= 800*1000;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
239 s->bit_rate_tolerance= s->bit_rate*10;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
240 s->qmin= 2;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
241 s->qmax= 31;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
242 s->mb_qmin= 2;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
243 s->mb_qmax= 31;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
244 s->rc_eq= "tex^qComp";
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
245 s->qcompress= 0.5;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
246 s->max_qdiff= 3;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
247 s->b_quant_factor=1.25;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
248 s->b_quant_offset=1.25;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
249 s->i_quant_factor=-0.8;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
250 s->i_quant_offset=0.0;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
251 s->error_concealment= 3;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
252 s->error_resilience= 1;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
253 s->workaround_bugs= FF_BUG_AUTODETECT;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
254 s->gop_size= 50;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
255 s->me_method= ME_EPZS;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
256 //s->get_buffer= avcodec_default_get_buffer;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
257 s->release_buffer= avcodec_default_release_buffer;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
258 s->get_format= avcodec_default_get_format;
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
259 s->me_subpel_quality=8;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
260 s->lmin= FF_QP2LAMBDA * s->qmin;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
261 s->lmax= FF_QP2LAMBDA * s->qmax;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
262 //s->sample_aspect_ratio= (AVRational){0,1};
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
263 s->ildct_cmp= FF_CMP_VSAD;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
264
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
265 s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
266 s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
267 s->palctrl = NULL;
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
268 //s->reget_buffer= avcodec_default_reget_buffer;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
269 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
270
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
271 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
272 * allocates a AVCodecContext and set it to defaults.
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
273 * this can be deallocated by simply calling free()
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
274 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
275 AVCodecContext *avcodec_alloc_context(void){
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
276 AVCodecContext *avctx= av_mallocz(sizeof(AVCodecContext));
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
277
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
278 if(avctx==NULL) return NULL;
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
279
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
280 avcodec_get_context_defaults(avctx);
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
281
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
282 return avctx;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
283 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
284
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
285 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
286 * allocates a AVPFrame and set it to defaults.
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
287 * this can be deallocated by simply calling free()
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
288 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
289 AVFrame *avcodec_alloc_frame(void){
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
290 AVFrame *pic= av_mallocz(sizeof(AVFrame));
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
291
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
292 return pic;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
293 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
294
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
295 int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
296 {
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
297 int ret;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
298
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
299 if(avctx->codec)
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
300 return -1;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
301
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
302 avctx->codec = codec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
303 avctx->codec_id = codec->id;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
304 avctx->frame_number = 0;
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
305 if (codec->priv_data_size > 0) {
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
306 avctx->priv_data = av_mallocz(codec->priv_data_size);
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
307 if (!avctx->priv_data)
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
308 return -ENOMEM;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
309 } else {
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
310 avctx->priv_data = NULL;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
311 }
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
312 ret = avctx->codec->init(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
313 if (ret < 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
314 av_freep(&avctx->priv_data);
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
315 return ret;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
316 }
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
317 return 0;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
318 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
319
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
320 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
321 const short *samples)
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
322 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
323 int ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
324
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
325 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples);
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
326 avctx->frame_number++;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
327 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
328 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
329
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
330 int avcodec_close(AVCodecContext *avctx)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
331 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
332 if (avctx->codec->close)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
333 avctx->codec->close(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
334 av_freep(&avctx->priv_data);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
335 avctx->codec = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
336 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
337 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
338
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
339 AVCodec *avcodec_find_encoder(enum CodecID id)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
340 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
341 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
342 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
343 while (p) {
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
344 if (p->encode != NULL && (enum CodecID)p->id == id)
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
345 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
346 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
347 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
348 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
349 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
350
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
351 AVCodec *avcodec_find_encoder_by_name(const char *name)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
352 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
353 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
354 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
355 while (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
356 if (p->encode != NULL && strcmp(name,p->name) == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
357 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
358 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
359 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
360 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
361 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
362
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
363 AVCodec *avcodec_find_decoder(enum CodecID id)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
364 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
365 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
366 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
367 while (p) {
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
368 if (p->decode != NULL && (enum CodecID)p->id == id)
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
369 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
370 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
371 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
372 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
373 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
374
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
375 AVCodec *avcodec_find_decoder_by_name(const char *name)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
376 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
377 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
378 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
379 while (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
380 if (p->decode != NULL && strcmp(name,p->name) == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
381 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
382 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
383 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
384 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
385 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
386
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
387 AVCodec *avcodec_find(enum CodecID id)
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
388 {
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
389 AVCodec *p;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
390 p = first_avcodec;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
391 while (p) {
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
392 if ((enum CodecID)p->id == id)
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
393 return p;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
394 p = p->next;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
395 }
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
396 return NULL;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
397 }
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
398
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
399 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
400 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
401 const char *codec_name;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
402 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
403 char buf1[32];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
404 char channels_str[100];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
405 int bitrate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
406
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
407 if (encode)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
408 p = avcodec_find_encoder(enc->codec_id);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
409 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
410 p = avcodec_find_decoder(enc->codec_id);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
411
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
412 if (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
413 codec_name = p->name;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
414 } else if (enc->codec_name[0] != '\0') {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
415 codec_name = enc->codec_name;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
416 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
417 /* output avi tags */
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
418 snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag);
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
419 codec_name = buf1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
420 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
421
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
422 switch(enc->codec_type) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
423 case CODEC_TYPE_AUDIO:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
424 snprintf(buf, buf_size,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
425 "Audio: %s",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
426 codec_name);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
427 switch (enc->channels) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
428 case 1:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
429 strcpy(channels_str, "mono");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
430 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
431 case 2:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
432 strcpy(channels_str, "stereo");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
433 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
434 case 6:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
435 strcpy(channels_str, "5:1");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
436 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
437 default:
818
07107d476f32 [svn] - remove some more stuff
nenolod
parents: 816
diff changeset
438 snprintf(channels_str, 100, "%d channels", enc->channels);
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
439 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
440 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
441 if (enc->sample_rate) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
442 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
443 ", %d Hz, %s",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
444 enc->sample_rate,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
445 channels_str);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
446 }
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
447
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
448 /* for PCM codecs, compute bitrate directly */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
449 switch(enc->codec_id) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
450 case CODEC_ID_PCM_S16LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
451 case CODEC_ID_PCM_S16BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
452 case CODEC_ID_PCM_U16LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
453 case CODEC_ID_PCM_U16BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
454 bitrate = enc->sample_rate * enc->channels * 16;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
455 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
456 case CODEC_ID_PCM_S8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
457 case CODEC_ID_PCM_U8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
458 case CODEC_ID_PCM_ALAW:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
459 case CODEC_ID_PCM_MULAW:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
460 bitrate = enc->sample_rate * enc->channels * 8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
461 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
462 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
463 bitrate = enc->bit_rate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
464 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
465 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
466 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
467 case CODEC_TYPE_DATA:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
468 snprintf(buf, buf_size, "Data: %s", codec_name);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
469 bitrate = enc->bit_rate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
470 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
471 default:
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
472 av_abort();
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
473 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
474 if (encode) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
475 if (enc->flags & CODEC_FLAG_PASS1)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
476 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
477 ", pass 1");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
478 if (enc->flags & CODEC_FLAG_PASS2)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
479 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
480 ", pass 2");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
481 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
482 if (bitrate != 0) {
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
483 snprintf(buf + strlen(buf), buf_size - strlen(buf),
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
484 ", %d kb/s", bitrate / 1000);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
485 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
486 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
487
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
488 unsigned avcodec_version( void )
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
489 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
490 return LIBAVCODEC_VERSION_INT;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
491 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
492
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
493 unsigned avcodec_build( void )
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
494 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
495 return LIBAVCODEC_BUILD;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
496 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
497
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
498 /* must be called before any other functions */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
499 void avcodec_init(void)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
500 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
501 static int inited = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
502
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
503 if (inited != 0)
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
504 return;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
505 inited = 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
506
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
507 dsputil_static_init();
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
508 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
509
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
510 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
511 * Flush buffers, should be called when seeking or when swicthing to a different stream.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
512 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
513 void avcodec_flush_buffers(AVCodecContext *avctx)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
514 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
515 if(avctx->codec->flush)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
516 avctx->codec->flush(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
517 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
518
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
519 void avcodec_default_free_buffers(AVCodecContext *s){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
520 int i, j;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
521
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
522 if(s->internal_buffer==NULL) return;
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
523
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
524 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
525 InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
526 for(j=0; j<4; j++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
527 av_freep(&buf->base[j]);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
528 buf->data[j]= NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
529 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
530 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
531 av_freep(&s->internal_buffer);
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
532
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
533 s->internal_buffer_count=0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
534 }
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
535 #if 0
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
536 char av_get_pict_type_char(int pict_type){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
537 switch(pict_type){
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
538 case I_TYPE: return 'I';
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
539 case P_TYPE: return 'P';
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
540 case B_TYPE: return 'B';
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
541 case S_TYPE: return 'S';
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
542 case SI_TYPE:return 'i';
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
543 case SP_TYPE:return 'p';
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
544 default: return '?';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
545 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
546 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
547
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
548 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
549 int exact=1, sign=0;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
550 int64_t gcd;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
551
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
552 assert(den != 0);
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
553
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
554 if(den < 0){
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
555 den= -den;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
556 nom= -nom;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
557 }
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
558
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
559 if(nom < 0){
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
560 nom= -nom;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
561 sign= 1;
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
562 }
815
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
563
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
564 gcd = ff_gcd(nom, den);
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
565 nom /= gcd;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
566 den /= gcd;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
567
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
568 if(nom > max || den > max){
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
569 AVRational a0={0,1}, a1={1,0};
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
570 exact=0;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
571
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
572 for(;;){
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
573 int64_t x= nom / den;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
574 int64_t a2n= x*a1.num + a0.num;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
575 int64_t a2d= x*a1.den + a0.den;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
576
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
577 if(a2n > max || a2d > max) break;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
578
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
579 nom %= den;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
580
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
581 a0= a1;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
582 a1= (AVRational){a2n, a2d};
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
583 if(nom==0) break;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
584 x= nom; nom=den; den=x;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
585 }
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
586 nom= a1.num;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
587 den= a1.den;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
588 }
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
589
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
590 assert(ff_gcd(nom, den) == 1);
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
591
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
592 if(sign) nom= -nom;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
593
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
594 *dst_nom = nom;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
595 *dst_den = den;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
596
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
597 return exact;
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
598 }
23a5aa2c545c [svn] - bork bork bork
nenolod
parents: 808
diff changeset
599 #endif