annotate Plugins/Input/wma/libffwma/utils.c @ 701:d539e5c5f730 trunk

[svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
author chainsaw
date Sun, 26 Feb 2006 13:08:35 -0800
parents b13e87374f73
children 1ddaf20ab50e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
1 /*
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
2 * utils for libavcodec
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard.
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
4 * Copyright (c) 2003 Michel Bardiaux for the av_log API
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
5 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
6 * Copyright (c) 2004 Roman Bogorodskiy (bmp-wma specific stuff)
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
7 *
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
8 * This library is free software; you can redistribute it and/or
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
11 * version 2 of the License, or (at your option) any later version.
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
12 *
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
13 * This library is distributed in the hope that it will be useful,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
16 * Lesser General Public License for more details.
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
17 *
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
19 * License along with this library; if not, write to the Free Software
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
21 */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
22
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
23 #include "avcodec.h"
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
24 #include "dsputil.h"
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
25 #include <stdarg.h>
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
26
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
27 void *av_mallocz(unsigned int size)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
28 {
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
29 void *ptr;
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
30
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
31 ptr = malloc(size);
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
32 if (!ptr)
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
33 return NULL;
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
34
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
35 memset(ptr, 0, size);
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
36
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
37 return ptr;
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
38 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
39
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
40 /**
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
41 * realloc which does nothing if the block is large enough
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
42 */
411
b13e87374f73 [svn] Care about pointer signedness.
chainsaw
parents: 218
diff changeset
43 void *av_fast_realloc(void *ptr, int *size, unsigned int min_size)
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
44 {
701
d539e5c5f730 [svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents: 411
diff changeset
45 if(min_size < (unsigned int)*size)
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
46 return ptr;
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
47
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
48 *size= min_size + 10*1024;
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
49
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
50 return realloc(ptr, *size);
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
51 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
52
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
53
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
54 /* allocation of static arrays - do not use for normal allocation */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
55 static unsigned int last_static = 0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
56 static char*** array_static = NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
57 static const unsigned int grow_static = 64; // ^2
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
58 void *__av_mallocz_static(void** location, unsigned int size)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
59 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
60 unsigned int l = (last_static + grow_static) & ~(grow_static - 1);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
61 void *ptr = av_mallocz(size);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
62 if (!ptr)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
63 return NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
64
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
65 if (location)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
66 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
67 if (l > last_static)
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
68 array_static = realloc(array_static, l);
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
69 array_static[last_static++] = (char**) location;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
70 *location = ptr;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
71 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
72 return ptr;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
73 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
74 /* free all static arrays and reset pointers to 0 */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
75 void av_free_static(void)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
76 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
77 if (array_static)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
78 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
79 unsigned i;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
80 for (i = 0; i < last_static; i++)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
81 {
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
82 free(*array_static[i]);
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
83 *array_static[i] = NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
84 }
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
85 free(array_static);
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
86 array_static = 0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
87 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
88 last_static = 0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
89 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
90
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
91 /* cannot call it directly because of 'void **' casting is not automatic */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
92 void __av_freep(void **ptr)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
93 {
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
94 free(*ptr);
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
95 *ptr = NULL;
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
96 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
97
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
98 /* encoder management */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
99 AVCodec *first_avcodec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
100
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
101 void register_avcodec(AVCodec *format)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
102 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
103 AVCodec **p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
104 p = &first_avcodec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
105 while (*p != NULL) p = &(*p)->next;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
106 *p = format;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
107 format->next = NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
108 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
109
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
110 typedef struct InternalBuffer{
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
111 int last_pic_num;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
112 uint8_t *base[4];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
113 uint8_t *data[4];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
114 int linesize[4];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
115 }InternalBuffer;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
116
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
117 #define INTERNAL_BUFFER_SIZE 32
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
118
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
119 #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
120
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
121 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
122 int w_align= 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
123 int h_align= 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
124
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
125 switch(s->pix_fmt){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
126 case PIX_FMT_YUV420P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
127 case PIX_FMT_YUV422:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
128 case PIX_FMT_YUV422P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
129 case PIX_FMT_YUV444P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
130 case PIX_FMT_GRAY8:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
131 case PIX_FMT_YUVJ420P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
132 case PIX_FMT_YUVJ422P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
133 case PIX_FMT_YUVJ444P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
134 w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
135 h_align= 16;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
136 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
137 case PIX_FMT_YUV411P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
138 w_align=32;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
139 h_align=8;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
140 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
141 case PIX_FMT_YUV410P:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
142 default:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
143 w_align= 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
144 h_align= 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
145 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
146 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
147
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
148 *width = ALIGN(*width , w_align);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
149 *height= ALIGN(*height, h_align);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
150 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
151
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
152 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
153 int i;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
154 InternalBuffer *buf, *last, temp;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
155
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
156 assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
157 assert(s->internal_buffer_count);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
158
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
159 buf = NULL; /* avoids warning */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
160 for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
161 buf= &((InternalBuffer*)s->internal_buffer)[i];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
162 if(buf->data[0] == pic->data[0])
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
163 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
164 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
165 assert(i < s->internal_buffer_count);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
166 s->internal_buffer_count--;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
167 last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
168
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
169 temp= *buf;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
170 *buf= *last;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
171 *last= temp;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
172
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
173 for(i=0; i<3; i++){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
174 pic->data[i]=NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
175 // pic->base[i]=NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
176 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
177 }
210
12004b385a96 [svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents: 142
diff changeset
178
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
179 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, enum PixelFormat * fmt){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
180 return fmt[0];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
181 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
182
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
183 void avcodec_get_context_defaults(AVCodecContext *s){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
184 s->bit_rate= 800*1000;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
185 s->bit_rate_tolerance= s->bit_rate*10;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
186 s->qmin= 2;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
187 s->qmax= 31;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
188 s->mb_qmin= 2;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
189 s->mb_qmax= 31;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
190 s->rc_eq= "tex^qComp";
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
191 s->qcompress= 0.5;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
192 s->max_qdiff= 3;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
193 s->b_quant_factor=1.25;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
194 s->b_quant_offset=1.25;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
195 s->i_quant_factor=-0.8;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
196 s->i_quant_offset=0.0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
197 s->error_concealment= 3;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
198 s->error_resilience= 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
199 s->workaround_bugs= FF_BUG_AUTODETECT;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
200 s->frame_rate_base= 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
201 s->frame_rate = 25;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
202 s->gop_size= 50;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
203 s->me_method= ME_EPZS;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
204 //s->get_buffer= avcodec_default_get_buffer;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
205 s->release_buffer= avcodec_default_release_buffer;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
206 s->get_format= avcodec_default_get_format;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
207 s->me_subpel_quality=8;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
208 s->lmin= FF_QP2LAMBDA * s->qmin;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
209 s->lmax= FF_QP2LAMBDA * s->qmax;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
210 //s->sample_aspect_ratio= (AVRational){0,1};
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
211 s->ildct_cmp= FF_CMP_VSAD;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
212
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
213 s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
214 s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
215 s->palctrl = NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
216 //s->reget_buffer= avcodec_default_reget_buffer;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
217 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
218
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
219 /**
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
220 * allocates a AVCodecContext and set it to defaults.
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
221 * this can be deallocated by simply calling free()
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
222 */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
223 AVCodecContext *avcodec_alloc_context(void){
210
12004b385a96 [svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents: 142
diff changeset
224 AVCodecContext *avctx= av_mallocz(sizeof(AVCodecContext));
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
225
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
226 if(avctx==NULL) return NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
227
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
228 avcodec_get_context_defaults(avctx);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
229
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
230 return avctx;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
231 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
232
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
233 /**
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
234 * allocates a AVPFrame and set it to defaults.
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
235 * this can be deallocated by simply calling free()
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
236 */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
237 AVFrame *avcodec_alloc_frame(void){
210
12004b385a96 [svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents: 142
diff changeset
238 AVFrame *pic= av_mallocz(sizeof(AVFrame));
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
239
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
240 return pic;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
241 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
242
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
243 int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
244 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
245 int ret;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
246
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
247 if(avctx->codec)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
248 return -1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
249
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
250 avctx->codec = codec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
251 avctx->codec_id = codec->id;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
252 avctx->frame_number = 0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
253 if (codec->priv_data_size > 0) {
210
12004b385a96 [svn] Sync with xmms-wma instead of bmp-wma & GThreadify. Does not explode, but does not play either.
chainsaw
parents: 142
diff changeset
254 avctx->priv_data = av_mallocz(codec->priv_data_size);
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
255 if (!avctx->priv_data)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
256 return -ENOMEM;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
257 } else {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
258 avctx->priv_data = NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
259 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
260 ret = avctx->codec->init(avctx);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
261 if (ret < 0) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
262 av_freep(&avctx->priv_data);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
263 return ret;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
264 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
265 return 0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
266 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
267
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
268 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
269 const short *samples)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
270 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
271 int ret;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
272
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
273 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
274 avctx->frame_number++;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
275 return ret;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
276 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
277
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
278 /* decode an audio frame. return -1 if error, otherwise return the
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
279 *number of bytes used. If no frame could be decompressed,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
280 *frame_size_ptr is zero. Otherwise, it is the decompressed frame
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
281 *size in BYTES. */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
282 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
283 int *frame_size_ptr,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
284 uint8_t *buf, int buf_size)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
285 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
286 int ret;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
287 ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
288 buf, buf_size);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
289 avctx->frame_number++;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
290 return ret;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
291 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
292
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
293 int avcodec_close(AVCodecContext *avctx)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
294 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
295 if (avctx->codec->close)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
296 avctx->codec->close(avctx);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
297 av_freep(&avctx->priv_data);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
298 avctx->codec = NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
299 return 0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
300 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
301
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
302 AVCodec *avcodec_find_encoder(enum CodecID id)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
303 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
304 AVCodec *p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
305 p = first_avcodec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
306 while (p) {
701
d539e5c5f730 [svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents: 411
diff changeset
307 if (p->encode != NULL && (enum CodecID)p->id == id)
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
308 return p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
309 p = p->next;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
310 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
311 return NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
312 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
313
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
314 AVCodec *avcodec_find_encoder_by_name(const char *name)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
315 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
316 AVCodec *p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
317 p = first_avcodec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
318 while (p) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
319 if (p->encode != NULL && strcmp(name,p->name) == 0)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
320 return p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
321 p = p->next;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
322 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
323 return NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
324 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
325
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
326 AVCodec *avcodec_find_decoder(enum CodecID id)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
327 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
328 AVCodec *p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
329 p = first_avcodec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
330 while (p) {
701
d539e5c5f730 [svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents: 411
diff changeset
331 if (p->decode != NULL && (enum CodecID)p->id == id)
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
332 return p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
333 p = p->next;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
334 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
335 return NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
336 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
337
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
338 AVCodec *avcodec_find_decoder_by_name(const char *name)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
339 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
340 AVCodec *p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
341 p = first_avcodec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
342 while (p) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
343 if (p->decode != NULL && strcmp(name,p->name) == 0)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
344 return p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
345 p = p->next;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
346 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
347 return NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
348 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
349
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
350 AVCodec *avcodec_find(enum CodecID id)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
351 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
352 AVCodec *p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
353 p = first_avcodec;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
354 while (p) {
701
d539e5c5f730 [svn] Fixes of the remaining GCC 4.1 warnings from external contributor Diego "Flameeyes" Petteno (Gentoo).
chainsaw
parents: 411
diff changeset
355 if ((enum CodecID)p->id == id)
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
356 return p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
357 p = p->next;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
358 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
359 return NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
360 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
361
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
362 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
363 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
364 const char *codec_name;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
365 AVCodec *p;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
366 char buf1[32];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
367 char channels_str[100];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
368 int bitrate;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
369
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
370 if (encode)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
371 p = avcodec_find_encoder(enc->codec_id);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
372 else
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
373 p = avcodec_find_decoder(enc->codec_id);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
374
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
375 if (p) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
376 codec_name = p->name;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
377 } else if (enc->codec_name[0] != '\0') {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
378 codec_name = enc->codec_name;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
379 } else {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
380 /* output avi tags */
218
0bea7509d6ba [svn] Working WMA support. I never said it would be pretty, neno, I should said it would play.
chainsaw
parents: 210
diff changeset
381 snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag);
137
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
382 codec_name = buf1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
383 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
384
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
385 switch(enc->codec_type) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
386 case CODEC_TYPE_AUDIO:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
387 snprintf(buf, buf_size,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
388 "Audio: %s",
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
389 codec_name);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
390 switch (enc->channels) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
391 case 1:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
392 strcpy(channels_str, "mono");
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
393 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
394 case 2:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
395 strcpy(channels_str, "stereo");
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
396 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
397 case 6:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
398 strcpy(channels_str, "5:1");
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
399 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
400 default:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
401 sprintf(channels_str, "%d channels", enc->channels);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
402 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
403 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
404 if (enc->sample_rate) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
405 snprintf(buf + strlen(buf), buf_size - strlen(buf),
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
406 ", %d Hz, %s",
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
407 enc->sample_rate,
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
408 channels_str);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
409 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
410
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
411 /* for PCM codecs, compute bitrate directly */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
412 switch(enc->codec_id) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
413 case CODEC_ID_PCM_S16LE:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
414 case CODEC_ID_PCM_S16BE:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
415 case CODEC_ID_PCM_U16LE:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
416 case CODEC_ID_PCM_U16BE:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
417 bitrate = enc->sample_rate * enc->channels * 16;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
418 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
419 case CODEC_ID_PCM_S8:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
420 case CODEC_ID_PCM_U8:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
421 case CODEC_ID_PCM_ALAW:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
422 case CODEC_ID_PCM_MULAW:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
423 bitrate = enc->sample_rate * enc->channels * 8;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
424 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
425 default:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
426 bitrate = enc->bit_rate;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
427 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
428 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
429 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
430 case CODEC_TYPE_DATA:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
431 snprintf(buf, buf_size, "Data: %s", codec_name);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
432 bitrate = enc->bit_rate;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
433 break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
434 default:
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
435 av_abort();
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
436 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
437 if (encode) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
438 if (enc->flags & CODEC_FLAG_PASS1)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
439 snprintf(buf + strlen(buf), buf_size - strlen(buf),
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
440 ", pass 1");
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
441 if (enc->flags & CODEC_FLAG_PASS2)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
442 snprintf(buf + strlen(buf), buf_size - strlen(buf),
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
443 ", pass 2");
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
444 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
445 if (bitrate != 0) {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
446 snprintf(buf + strlen(buf), buf_size - strlen(buf),
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
447 ", %d kb/s", bitrate / 1000);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
448 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
449 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
450
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
451 unsigned avcodec_version( void )
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
452 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
453 return LIBAVCODEC_VERSION_INT;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
454 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
455
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
456 unsigned avcodec_build( void )
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
457 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
458 return LIBAVCODEC_BUILD;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
459 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
460
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
461 /* must be called before any other functions */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
462 void avcodec_init(void)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
463 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
464 static int inited = 0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
465
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
466 if (inited != 0)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
467 return;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
468 inited = 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
469
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
470 dsputil_static_init();
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
471 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
472
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
473 /**
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
474 * Flush buffers, should be called when seeking or when swicthing to a different stream.
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
475 */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
476 void avcodec_flush_buffers(AVCodecContext *avctx)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
477 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
478 if(avctx->codec->flush)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
479 avctx->codec->flush(avctx);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
480 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
481
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
482 void avcodec_default_free_buffers(AVCodecContext *s){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
483 int i, j;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
484
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
485 if(s->internal_buffer==NULL) return;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
486
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
487 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
488 InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i];
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
489 for(j=0; j<4; j++){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
490 av_freep(&buf->base[j]);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
491 buf->data[j]= NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
492 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
493 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
494 av_freep(&s->internal_buffer);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
495
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
496 s->internal_buffer_count=0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
497 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
498 #if 0
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
499 char av_get_pict_type_char(int pict_type){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
500 switch(pict_type){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
501 case I_TYPE: return 'I';
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
502 case P_TYPE: return 'P';
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
503 case B_TYPE: return 'B';
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
504 case S_TYPE: return 'S';
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
505 case SI_TYPE:return 'i';
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
506 case SP_TYPE:return 'p';
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
507 default: return '?';
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
508 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
509 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
510
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
511 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
512 int exact=1, sign=0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
513 int64_t gcd;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
514
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
515 assert(den != 0);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
516
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
517 if(den < 0){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
518 den= -den;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
519 nom= -nom;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
520 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
521
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
522 if(nom < 0){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
523 nom= -nom;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
524 sign= 1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
525 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
526
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
527 gcd = ff_gcd(nom, den);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
528 nom /= gcd;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
529 den /= gcd;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
530
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
531 if(nom > max || den > max){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
532 AVRational a0={0,1}, a1={1,0};
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
533 exact=0;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
534
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
535 for(;;){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
536 int64_t x= nom / den;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
537 int64_t a2n= x*a1.num + a0.num;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
538 int64_t a2d= x*a1.den + a0.den;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
539
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
540 if(a2n > max || a2d > max) break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
541
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
542 nom %= den;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
543
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
544 a0= a1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
545 a1= (AVRational){a2n, a2d};
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
546 if(nom==0) break;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
547 x= nom; nom=den; den=x;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
548 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
549 nom= a1.num;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
550 den= a1.den;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
551 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
552
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
553 assert(ff_gcd(nom, den) == 1);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
554
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
555 if(sign) nom= -nom;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
556
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
557 *dst_nom = nom;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
558 *dst_den = den;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
559
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
560 return exact;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
561 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
562 #endif
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
563 int64_t av_rescale(int64_t a, int b, int c){
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
564 uint64_t h, l;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
565 assert(c > 0);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
566 assert(b >=0);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
567
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
568 if(a<0) return -av_rescale(-a, b, c);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
569
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
570 h= a>>32;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
571 if(h==0) return a*b/c;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
572
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
573 l= a&0xFFFFFFFF;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
574 l *= b;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
575 h *= b;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
576
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
577 l += (h%c)<<32;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
578
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
579 return ((h/c)<<32) + l/c;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
580 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
581
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
582 /* av_log API */
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
583
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
584 #ifdef AV_LOG_TRAP_PRINTF
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
585 #undef stderr
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
586 #undef fprintf
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
587 #endif
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
588
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
589 static int av_log_level = AV_LOG_DEBUG;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
590
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
591 static void av_log_default_callback(AVCodecContext* avctx, int level, const char* fmt, va_list vl)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
592 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
593 static int print_prefix=1;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
594
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
595 if(level>av_log_level)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
596 return;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
597 if(avctx && print_prefix)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
598 fprintf(stderr, "[%s @ %p]", avctx->codec ? avctx->codec->name : "?", avctx);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
599
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
600 print_prefix= strstr(fmt, "\n") != NULL;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
601
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
602 vfprintf(stderr, fmt, vl);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
603 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
604
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
605 static void (*av_log_callback)(AVCodecContext*, int, const char*, va_list) = av_log_default_callback;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
606
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
607 void av_log(AVCodecContext* avctx, int level, const char *fmt, ...)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
608 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
609 va_list vl;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
610 va_start(vl, fmt);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
611 av_vlog(avctx, level, fmt, vl);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
612 va_end(vl);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
613 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
614
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
615 void av_vlog(AVCodecContext* avctx, int level, const char *fmt, va_list vl)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
616 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
617 av_log_callback(avctx, level, fmt, vl);
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
618 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
619
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
620 int av_log_get_level(void)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
621 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
622 return av_log_level;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
623 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
624
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
625 void av_log_set_level(int level)
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
626 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
627 av_log_level = level;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
628 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
629
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
630 void av_log_set_callback(void (*callback)(AVCodecContext*, int, const char*, va_list))
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
631 {
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
632 av_log_callback = callback;
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
633 }
b8d4c1faa6d7 [svn] Import WMA decoder into SVN.
nenolod
parents:
diff changeset
634