annotate src/ffmpeg/libavcodec/utils.c @ 808:e8776388b02a trunk

[svn] - add ffmpeg
author nenolod
date Mon, 12 Mar 2007 11:18:54 -0700
parents
children 23a5aa2c545c
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.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
5 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
6 * This file is part of FFmpeg.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
7 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
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
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
12 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
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
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
21 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
22
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
23 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
24 * @file utils.c
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
25 * utils.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
26 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
27
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
28 #include "avcodec.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
29 #include "dsputil.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
30 #include "mpegvideo.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
31 #include "integer.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
32 #include "opt.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
33 #include "crc.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
34 #include <stdarg.h>
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
35 #include <limits.h>
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
36 #include <float.h>
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
37 #ifdef __MINGW32__
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
38 #include <fcntl.h>
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
39 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
40
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
41 const uint8_t ff_reverse[256]={
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
42 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
43 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
44 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
45 0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
46 0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
47 0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
48 0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
49 0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
50 0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
51 0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
52 0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
53 0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
54 0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
55 0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
56 0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
57 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
58 };
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
59
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
60 static int volatile entangled_thread_counter=0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
61
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
62 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
63 * realloc which does nothing if the block is large enough
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
64 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
65 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
66 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
67 if(min_size < *size)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
68 return ptr;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
69
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
70 *size= FFMAX(17*min_size/16 + 32, min_size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
71
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
72 return av_realloc(ptr, *size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
73 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
74
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
75 static unsigned int last_static = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
76 static unsigned int allocated_static = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
77 static void** array_static = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
78
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
79 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
80 * allocation of static arrays - do not use for normal allocation.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
81 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
82 void *av_mallocz_static(unsigned int size)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
83 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
84 void *ptr = av_mallocz(size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
85
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
86 if(ptr){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
87 array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
88 if(!array_static)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
89 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
90 array_static[last_static++] = ptr;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
91 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
92
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
93 return ptr;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
94 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
95
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
96 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
97 * same as above, but does realloc
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
98 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
99
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
100 void *av_realloc_static(void *ptr, unsigned int size)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
101 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
102 int i;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
103 if(!ptr)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
104 return av_mallocz_static(size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
105 /* Look for the old ptr */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
106 for(i = 0; i < last_static; i++) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
107 if(array_static[i] == ptr) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
108 array_static[i] = av_realloc(array_static[i], size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
109 return array_static[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
110 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
111 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
112 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
113
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
114 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
115
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
116 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
117 * free all static arrays and reset pointers to 0.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
118 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
119 void av_free_static(void)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
120 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
121 while(last_static){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
122 av_freep(&array_static[--last_static]);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
123 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
124 av_freep(&array_static);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
125 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
126
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
127 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
128 * Call av_free_static automatically before it's too late
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
129 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
130
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
131 static void do_free(void) __attribute__ ((destructor));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
132
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
133 static void do_free(void)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
134 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
135 av_free_static();
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
136 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
137
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
138
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
139 /* encoder management */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
140 AVCodec *first_avcodec = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
141
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
142 void register_avcodec(AVCodec *format)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
143 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
144 AVCodec **p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
145 p = &first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
146 while (*p != NULL) p = &(*p)->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
147 *p = format;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
148 format->next = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
149 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
150
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
151 void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
152 s->coded_width = width;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
153 s->coded_height= height;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
154 s->width = -((-width )>>s->lowres);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
155 s->height= -((-height)>>s->lowres);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
156 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
157
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
158 typedef struct InternalBuffer{
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
159 int last_pic_num;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
160 uint8_t *base[4];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
161 uint8_t *data[4];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
162 int linesize[4];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
163 }InternalBuffer;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
164
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
165 #define INTERNAL_BUFFER_SIZE 32
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
166
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
167 #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
168
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
169 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
170 int w_align= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
171 int h_align= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
172
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
173 switch(s->pix_fmt){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
174 case PIX_FMT_YUV420P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
175 case PIX_FMT_YUV422:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
176 case PIX_FMT_UYVY422:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
177 case PIX_FMT_YUV422P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
178 case PIX_FMT_YUV444P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
179 case PIX_FMT_GRAY8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
180 case PIX_FMT_YUVJ420P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
181 case PIX_FMT_YUVJ422P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
182 case PIX_FMT_YUVJ444P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
183 w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
184 h_align= 16;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
185 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
186 case PIX_FMT_YUV411P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
187 case PIX_FMT_UYVY411:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
188 w_align=32;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
189 h_align=8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
190 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
191 case PIX_FMT_YUV410P:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
192 if(s->codec_id == CODEC_ID_SVQ1){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
193 w_align=64;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
194 h_align=64;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
195 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
196 case PIX_FMT_RGB555:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
197 if(s->codec_id == CODEC_ID_RPZA){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
198 w_align=4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
199 h_align=4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
200 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
201 case PIX_FMT_PAL8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
202 if(s->codec_id == CODEC_ID_SMC){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
203 w_align=4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
204 h_align=4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
205 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
206 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
207 case PIX_FMT_BGR24:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
208 if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
209 w_align=4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
210 h_align=4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
211 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
212 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
213 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
214 w_align= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
215 h_align= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
216 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
217 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
218
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
219 *width = ALIGN(*width , w_align);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
220 *height= ALIGN(*height, h_align);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
221 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
222
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
223 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
224 if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/4)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
225 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
226
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
227 av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
228 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
229 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
230
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
231 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
232 int i;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
233 int w= s->width;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
234 int h= s->height;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
235 InternalBuffer *buf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
236 int *picture_number;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
237
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
238 assert(pic->data[0]==NULL);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
239 assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
240
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
241 if(avcodec_check_dimensions(s,w,h))
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
242 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
243
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
244 if(s->internal_buffer==NULL){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
245 s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
246 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
247 #if 0
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
248 s->internal_buffer= av_fast_realloc(
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
249 s->internal_buffer,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
250 &s->internal_buffer_size,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
251 sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)/*FIXME*/
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
252 );
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
253 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
254
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
255 buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
256 picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
257 (*picture_number)++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
258
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
259 if(buf->base[0]){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
260 pic->age= *picture_number - buf->last_pic_num;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
261 buf->last_pic_num= *picture_number;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
262 }else{
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
263 int h_chroma_shift, v_chroma_shift;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
264 int pixel_size, size[3];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
265 AVPicture picture;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
266
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
267 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
268
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
269 avcodec_align_dimensions(s, &w, &h);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
270
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
271 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
272 w+= EDGE_WIDTH*2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
273 h+= EDGE_WIDTH*2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
274 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
275 avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
276 pixel_size= picture.linesize[0]*8 / w;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
277 //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d\n", (int)picture.data[1], w, h, s->pix_fmt);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
278 assert(pixel_size>=1);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
279 //FIXME next ensures that linesize= 2^x uvlinesize, thats needed because some MC code assumes it
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
280 if(pixel_size == 3*8)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
281 w= ALIGN(w, STRIDE_ALIGN<<h_chroma_shift);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
282 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
283 w= ALIGN(pixel_size*w, STRIDE_ALIGN<<(h_chroma_shift+3)) / pixel_size;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
284 size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
285 size[0] = picture.linesize[0] * h;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
286 size[1] -= size[0];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
287 if(picture.data[2])
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
288 size[1]= size[2]= size[1]/2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
289 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
290 size[2]= 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
291
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
292 buf->last_pic_num= -256*256*256*64;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
293 memset(buf->base, 0, sizeof(buf->base));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
294 memset(buf->data, 0, sizeof(buf->data));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
295
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
296 for(i=0; i<3 && size[i]; i++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
297 const int h_shift= i==0 ? 0 : h_chroma_shift;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
298 const int v_shift= i==0 ? 0 : v_chroma_shift;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
299
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
300 buf->linesize[i]= picture.linesize[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
301
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
302 buf->base[i]= av_malloc(size[i]+16); //FIXME 16
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
303 if(buf->base[i]==NULL) return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
304 memset(buf->base[i], 128, size[i]);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
305
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
306 // no edge if EDEG EMU or not planar YUV, we check for PAL8 redundantly to protect against a exploitable bug regression ...
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
307 if((s->flags&CODEC_FLAG_EMU_EDGE) || (s->pix_fmt == PIX_FMT_PAL8) || !size[2])
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
308 buf->data[i] = buf->base[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
309 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
310 buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
311 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
312 pic->age= 256*256*256*64;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
313 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
314 pic->type= FF_BUFFER_TYPE_INTERNAL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
315
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
316 for(i=0; i<4; i++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
317 pic->base[i]= buf->base[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
318 pic->data[i]= buf->data[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
319 pic->linesize[i]= buf->linesize[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
320 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
321 s->internal_buffer_count++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
322
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
323 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
324 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
325
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
326 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
327 int i;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
328 InternalBuffer *buf, *last, temp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
329
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
330 assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
331 assert(s->internal_buffer_count);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
332
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
333 buf = NULL; /* avoids warning */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
334 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
335 buf= &((InternalBuffer*)s->internal_buffer)[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
336 if(buf->data[0] == pic->data[0])
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
337 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
338 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
339 assert(i < s->internal_buffer_count);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
340 s->internal_buffer_count--;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
341 last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
342
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
343 temp= *buf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
344 *buf= *last;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
345 *last= temp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
346
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
347 for(i=0; i<3; i++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
348 pic->data[i]=NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
349 // pic->base[i]=NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
350 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
351 //printf("R%X\n", pic->opaque);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
352 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
353
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
354 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
355 AVFrame temp_pic;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
356 int i;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
357
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
358 /* If no picture return a new buffer */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
359 if(pic->data[0] == NULL) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
360 /* We will copy from buffer, so must be readable */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
361 pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
362 return s->get_buffer(s, pic);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
363 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
364
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
365 /* If internal buffer type return the same buffer */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
366 if(pic->type == FF_BUFFER_TYPE_INTERNAL)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
367 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
368
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
369 /*
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
370 * Not internal type and reget_buffer not overridden, emulate cr buffer
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
371 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
372 temp_pic = *pic;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
373 for(i = 0; i < 4; i++)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
374 pic->data[i] = pic->base[i] = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
375 pic->opaque = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
376 /* Allocate new frame */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
377 if (s->get_buffer(s, pic))
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
378 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
379 /* Copy image data from old buffer to new buffer */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
380 img_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
381 s->height);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
382 s->release_buffer(s, &temp_pic); // Release old frame
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
383 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
384 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
385
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
386 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
387 int i;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
388
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
389 for(i=0; i<count; i++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
390 int r= func(c, arg[i]);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
391 if(ret) ret[i]= r;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
392 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
393 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
394 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
395
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
396 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
397 return fmt[0];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
398 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
399
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
400 static const char* context_to_name(void* ptr) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
401 AVCodecContext *avc= ptr;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
402
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
403 if(avc && avc->codec && avc->codec->name)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
404 return avc->codec->name;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
405 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
406 return "NULL";
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
407 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
408
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
409 #define OFFSET(x) offsetof(AVCodecContext,x)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
410 #define DEFAULT 0 //should be NAN but it doesnt work as its not a constant in glibc as required by ANSI/ISO C
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
411 //these names are too long to be readable
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
412 #define V AV_OPT_FLAG_VIDEO_PARAM
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
413 #define A AV_OPT_FLAG_AUDIO_PARAM
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
414 #define S AV_OPT_FLAG_SUBTITLE_PARAM
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
415 #define E AV_OPT_FLAG_ENCODING_PARAM
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
416 #define D AV_OPT_FLAG_DECODING_PARAM
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
417
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
418 #define AV_CODEC_DEFAULT_BITRATE 200*1000
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
419
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
420 static const AVOption options[]={
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
421 {"b", "set video bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE, INT_MIN, INT_MAX, V|A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
422 {"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, AV_CODEC_DEFAULT_BITRATE*20, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
423 {"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|A|E|D, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
424 {"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_4MV, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
425 {"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_OBMC, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
426 {"qpel", "use 1/4 pel motion compensation", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QPEL, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
427 {"loop", "use loop filter", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_LOOP_FILTER, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
428 {"qscale", "use fixed qscale", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QSCALE, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
429 {"gmc", "use gmc", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_GMC, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
430 {"mv0", "always try a mb with mv=<0,0>", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_MV0, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
431 {"part", "use data partitioning", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PART, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
432 {"input_preserved", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG_INPUT_PRESERVED, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
433 {"pass1", "use internal 2pass ratecontrol in first pass mode", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PASS1, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
434 {"pass2", "use internal 2pass ratecontrol in second pass mode", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PASS2, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
435 {"extern_huff", "use external huffman table (for mjpeg)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_EXTERN_HUFF, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
436 {"gray", "only decode/encode grayscale", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_GRAY, INT_MIN, INT_MAX, V|E|D, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
437 {"emu_edge", "don't draw edges", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_EMU_EDGE, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
438 {"psnr", "error[?] variables will be set during encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PSNR, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
439 {"truncated", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG_TRUNCATED, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
440 {"naq", "normalize adaptive quantization", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_NORMALIZE_AQP, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
441 {"ildct", "use interlaced dct", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_INTERLACED_DCT, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
442 {"low_delay", "force low delay", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_LOW_DELAY, INT_MIN, INT_MAX, V|D, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
443 {"alt", "enable alternate scantable (mpeg2/mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_ALT_SCAN, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
444 {"trell", "use trellis quantization", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_TRELLIS_QUANT, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
445 {"global_header", "place global headers in extradata instead of every keyframe", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_GLOBAL_HEADER, INT_MIN, INT_MAX, 0, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
446 {"bitexact", "use only bitexact stuff (except (i)dct)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_BITEXACT, INT_MIN, INT_MAX, A|V|S|D|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
447 {"aic", "h263 advanced intra coding / mpeg4 ac prediction", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_AC_PRED, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
448 {"umv", "use unlimited motion vectors", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_H263P_UMV, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
449 {"cbp", "use rate distortion optimization for cbp", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_CBP_RD, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
450 {"qprd", "use rate distortion optimization for qp selection", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QP_RD, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
451 {"aiv", "h263 alternative inter vlc", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_H263P_AIV, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
452 {"slice", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG_H263P_SLICE_STRUCT, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
453 {"ilme", "interlaced motion estimation", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_INTERLACED_ME, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
454 {"scan_offset", "will reserve space for svcd scan offset user data", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_SVCD_SCAN_OFFSET, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
455 {"cgop", "closed gop", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_CLOSED_GOP, INT_MIN, INT_MAX, V|E, "flags"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
456 {"fast", "allow non spec compliant speedup tricks", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_FAST, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
457 {"sgop", "strictly enforce gop size", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_STRICT_GOP, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
458 {"noout", "skip bitstream encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NO_OUTPUT, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
459 {"local_header", "place global headers at every keyframe instead of in extradata", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_LOCAL_HEADER, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
460 {"sub_id", NULL, OFFSET(sub_id), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
461 {"me_method", "set motion estimation method", OFFSET(me_method), FF_OPT_TYPE_INT, ME_EPZS, INT_MIN, INT_MAX, V|E, "me_method"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
462 {"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
463 {"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
464 {"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, 12, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
465 {"rate_emu", NULL, OFFSET(rate_emu), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
466 {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
467 {"ac", "set number of audio channels", OFFSET(channels), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
468 {"cutoff", "set cutoff bandwidth", OFFSET(cutoff), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
469 {"frame_size", NULL, OFFSET(frame_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
470 {"frame_number", NULL, OFFSET(frame_number), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
471 {"real_pict_num", NULL, OFFSET(real_pict_num), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
472 {"delay", NULL, OFFSET(delay), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
473 {"qcomp", "video quantizer scale compression (VBR)", OFFSET(qcompress), FF_OPT_TYPE_FLOAT, 0.5, FLT_MIN, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
474 {"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), FF_OPT_TYPE_FLOAT, 0.5, FLT_MIN, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
475 {"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, 2, 1, 51, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
476 {"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, 31, 1, 51, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
477 {"qdiff", "max difference between the quantizer scale (VBR)", OFFSET(max_qdiff), FF_OPT_TYPE_INT, 3, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
478 {"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, DEFAULT, 0, FF_MAX_B_FRAMES, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
479 {"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
480 {"rc_strategy", NULL, OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
481 {"b_strategy", NULL, OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
482 {"hurry_up", NULL, OFFSET(hurry_up), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
483 {"rtp_mode", NULL, OFFSET(rtp_mode), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
484 {"rtp_payload_size", NULL, OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
485 {"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
486 {"header_bits", NULL, OFFSET(header_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
487 {"i_tex_bits", NULL, OFFSET(i_tex_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
488 {"p_tex_bits", NULL, OFFSET(p_tex_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
489 {"i_count", NULL, OFFSET(i_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
490 {"p_count", NULL, OFFSET(p_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
491 {"skip_count", NULL, OFFSET(skip_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
492 {"misc_bits", NULL, OFFSET(misc_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
493 {"frame_bits", NULL, OFFSET(frame_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
494 {"codec_tag", NULL, OFFSET(codec_tag), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
495 {"bug", "workaround not auto detected encoder bugs", OFFSET(workaround_bugs), FF_OPT_TYPE_FLAGS, FF_BUG_AUTODETECT, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
496 {"autodetect", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AUTODETECT, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
497 {"old_msmpeg4", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_OLD_MSMPEG4, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
498 {"xvid_ilace", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_XVID_ILACE, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
499 {"ump4", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_UMP4, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
500 {"no_padding", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_NO_PADDING, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
501 {"amv", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AMV, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
502 {"ac_vlc", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AC_VLC, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
503 {"qpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_QPEL_CHROMA, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
504 {"std_qpel", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_STD_QPEL, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
505 {"qpel_chroma2", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_QPEL_CHROMA2, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
506 {"direct_blocksize", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_DIRECT_BLOCKSIZE, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
507 {"edge", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_EDGE, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
508 {"hpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_HPEL_CHROMA, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
509 {"dc_clip", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_DC_CLIP, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
510 {"ms", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_MS, INT_MIN, INT_MAX, V|D, "bug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
511 {"lelim", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)", OFFSET(luma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
512 {"celim", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)", OFFSET(chroma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
513 {"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "strict"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
514 {"very", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_VERY_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
515 {"strict", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
516 {"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|E, "strict"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
517 {"inofficial", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|E, "strict"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
518 {"experimental", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
519 {"b_qoffset", "qp offset between p and b frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
520 {"er", NULL, OFFSET(error_resilience), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
521 {"careful", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
522 {"compliant", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_COMPLIANT, INT_MIN, INT_MAX, V|D, "er"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
523 {"aggressive", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_AGGRESSIVE, INT_MIN, INT_MAX, V|D, "er"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
524 {"very_aggressive", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_VERY_AGGRESSIVE, INT_MIN, INT_MAX, V|D, "er"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
525 {"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
526 {"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
527 {"parse_only", NULL, OFFSET(parse_only), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
528 {"mpeg_quant", NULL, OFFSET(mpeg_quant), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
529 {"stats_out", NULL, OFFSET(stats_out), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
530 {"stats_in", NULL, OFFSET(stats_in), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
531 {"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", OFFSET(rc_qsquish), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 99, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
532 {"rc_qmod_amp", NULL, OFFSET(rc_qmod_amp), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
533 {"rc_qmod_freq", NULL, OFFSET(rc_qmod_freq), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
534 {"rc_override_count", NULL, OFFSET(rc_override_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
535 {"rc_eq", "set rate control equation", OFFSET(rc_eq), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
536 {"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
537 {"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
538 {"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
539 {"rc_buf_aggressivity", NULL, OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, 1.0, FLT_MIN, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
540 {"i_qfactor", "qp factor between p and i frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, -0.8, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
541 {"i_qoffset", "qp offset between p and i frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, 0.0, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
542 {"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
543 {"dct", NULL, OFFSET(dct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
544 {"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_AUTO, INT_MIN, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
545 {"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_FASTINT, INT_MIN, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
546 {"int", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_INT, INT_MIN, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
547 {"mmx", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_MMX, INT_MIN, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
548 {"mlib", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_MLIB, INT_MIN, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
549 {"altivec", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_ALTIVEC, INT_MIN, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
550 {"faan", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_FAAN, INT_MIN, INT_MAX, V|E, "dct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
551 {"lumi_mask", "lumimasking", OFFSET(lumi_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
552 {"tcplx_mask", "temporal complexity masking", OFFSET(temporal_cplx_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
553 {"scplx_mask", "spatial complexity masking", OFFSET(spatial_cplx_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
554 {"p_mask", "inter masking", OFFSET(p_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
555 {"dark_mask", "darkness masking", OFFSET(dark_masking), FF_OPT_TYPE_FLOAT, 0, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
556 {"unused", NULL, OFFSET(unused), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
557 {"idct", NULL, OFFSET(idct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
558 {"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_AUTO, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
559 {"int", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_INT, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
560 {"simple", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLE, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
561 {"simplemmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLEMMX, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
562 {"libmpeg2mmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_LIBMPEG2MMX, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
563 {"ps2", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_PS2, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
564 {"mlib", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_MLIB, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
565 {"arm", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_ARM, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
566 {"altivec", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_ALTIVEC, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
567 {"sh4", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SH4, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
568 {"simplearm", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLEARM, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
569 {"simplearmv5te", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLEARMV5TE, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
570 {"h264", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_H264, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
571 {"vp3", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_VP3, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
572 {"ipp", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_IPP, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
573 {"xvidmmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_XVIDMMX, INT_MIN, INT_MAX, V|E|D, "idct"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
574 {"slice_count", NULL, OFFSET(slice_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
575 {"ec", NULL, OFFSET(error_concealment), FF_OPT_TYPE_FLAGS, 3, INT_MIN, INT_MAX, V|D, "ec"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
576 {"guess_mvs", NULL, 0, FF_OPT_TYPE_CONST, FF_EC_GUESS_MVS, INT_MIN, INT_MAX, V|D, "ec"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
577 {"deblock", NULL, 0, FF_OPT_TYPE_CONST, FF_EC_DEBLOCK, INT_MIN, INT_MAX, V|D, "ec"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
578 {"bits_per_sample", NULL, OFFSET(bits_per_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
579 {"pred", "prediction method", OFFSET(prediction_method), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "pred"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
580 {"left", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_LEFT, INT_MIN, INT_MAX, V|E, "pred"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
581 {"plane", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_PLANE, INT_MIN, INT_MAX, V|E, "pred"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
582 {"median", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_MEDIAN, INT_MIN, INT_MAX, V|E, "pred"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
583 {"aspect", NULL, OFFSET(sample_aspect_ratio), FF_OPT_TYPE_RATIONAL, DEFAULT, 0, 10, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
584 {"debug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, V|A|S|E|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
585 {"pict", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_PICT_INFO, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
586 {"rc", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_RC, INT_MIN, INT_MAX, V|E, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
587 {"bitstream", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_BITSTREAM, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
588 {"mb_type", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
589 {"qp", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_QP, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
590 {"mv", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MV, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
591 {"dct_coeff", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_DCT_COEFF, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
592 {"skip", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_SKIP, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
593 {"startcode", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_STARTCODE, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
594 {"pts", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_PTS, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
595 {"er", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_ER, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
596 {"mmco", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MMCO, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
597 {"bugs", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_BUGS, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
598 {"vis_qp", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_QP, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
599 {"vis_mb_type", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
600 {"vismv", "visualize motion vectors", OFFSET(debug_mv), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|D, "debug_mv"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
601 {"pf", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_P_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
602 {"bf", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
603 {"bb", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_BACK, INT_MIN, INT_MAX, V|D, "debug_mv"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
604 {"mb_qmin", NULL, OFFSET(mb_qmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
605 {"mb_qmax", NULL, OFFSET(mb_qmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
606 {"cmp", "full pel me compare function", OFFSET(me_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
607 {"subcmp", "sub pel me compare function", OFFSET(me_sub_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
608 {"mbcmp", "macroblock compare function", OFFSET(mb_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
609 {"ildctcmp", "interlaced dct compare function", OFFSET(ildct_cmp), FF_OPT_TYPE_INT, FF_CMP_VSAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
610 {"dia_size", NULL, OFFSET(dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
611 {"last_pred", NULL, OFFSET(last_predictor_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
612 {"preme", "pre motion estimation", OFFSET(pre_me), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
613 {"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
614 {"sad", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
615 {"sse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
616 {"satd", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SATD, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
617 {"dct", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_DCT, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
618 {"psnr", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_PSNR, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
619 {"bit", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_BIT, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
620 {"rd", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_RD, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
621 {"zero", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_ZERO, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
622 {"vsad", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_VSAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
623 {"vsse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_VSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
624 {"nsse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_NSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
625 #ifdef CONFIG_SNOW_ENCODER
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
626 {"w53", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_W53, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
627 {"w97", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_W97, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
628 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
629 {"dctmax", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_DCTMAX, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
630 {"chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_CHROMA, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
631 {"pre_dia_size", NULL, OFFSET(pre_dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
632 {"subq", "sub pel motion estimation quality", OFFSET(me_subpel_quality), FF_OPT_TYPE_INT, 8, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
633 {"dtg_active_format", NULL, OFFSET(dtg_active_format), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
634 {"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
635 {"ibias", "intra quant bias", OFFSET(intra_quant_bias), FF_OPT_TYPE_INT, FF_DEFAULT_QUANT_BIAS, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
636 {"pbias", "inter quant bias", OFFSET(inter_quant_bias), FF_OPT_TYPE_INT, FF_DEFAULT_QUANT_BIAS, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
637 {"color_table_id", NULL, OFFSET(color_table_id), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
638 {"internal_buffer_count", NULL, OFFSET(internal_buffer_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
639 {"global_quality", NULL, OFFSET(global_quality), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
640 {"coder", NULL, OFFSET(coder_type), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "coder"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
641 {"vlc", "variable length coder / huffman coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_VLC, INT_MIN, INT_MAX, V|E, "coder"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
642 {"ac", "arithmetic coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_AC, INT_MIN, INT_MAX, V|E, "coder"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
643 {"context", "context model", OFFSET(context_model), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
644 {"slice_flags", NULL, OFFSET(slice_flags), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
645 {"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
646 {"mbd", NULL, OFFSET(mb_decision), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "mbd"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
647 {"simple", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_SIMPLE, INT_MIN, INT_MAX, V|E, "mbd"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
648 {"bits", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_BITS, INT_MIN, INT_MAX, V|E, "mbd"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
649 {"rd", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_RD, INT_MIN, INT_MAX, V|E, "mbd"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
650 {"stream_codec_tag", NULL, OFFSET(stream_codec_tag), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
651 {"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
652 {"lmin", "min lagrange factor (VBR)", OFFSET(lmin), FF_OPT_TYPE_INT, 2*FF_QP2LAMBDA, 0, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
653 {"lmax", "max lagrange factor (VBR)", OFFSET(lmax), FF_OPT_TYPE_INT, 31*FF_QP2LAMBDA, 0, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
654 {"nr", "noise reduction", OFFSET(noise_reduction), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
655 {"rc_init_occupancy", NULL, OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
656 {"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
657 {"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|A|E|D, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
658 {"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
659 {"antialias", NULL, OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
660 {"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
661 {"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_FASTINT, INT_MIN, INT_MAX, V|D, "aa"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
662 {"int", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_INT, INT_MIN, INT_MAX, V|D, "aa"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
663 {"float", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_FLOAT, INT_MIN, INT_MAX, V|D, "aa"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
664 {"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
665 {"threads", NULL, OFFSET(thread_count), FF_OPT_TYPE_INT, 1, INT_MIN, INT_MAX, V|E|D},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
666 {"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
667 {"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
668 {"dc", "intra_dc_precision", OFFSET(intra_dc_precision), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
669 {"nssew", "nsse weight", OFFSET(nsse_weight), FF_OPT_TYPE_INT, 8, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
670 {"skip_top", NULL, OFFSET(skip_top), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
671 {"skip_bottom", NULL, OFFSET(skip_bottom), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
672 {"profile", NULL, OFFSET(profile), FF_OPT_TYPE_INT, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
673 {"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
674 {"level", NULL, OFFSET(level), FF_OPT_TYPE_INT, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
675 {"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
676 {"lowres", NULL, OFFSET(lowres), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|D},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
677 {"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
678 {"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
679 {"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
680 {"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), FF_OPT_TYPE_INT, FF_CMP_DCTMAX, INT_MIN, INT_MAX, V|E, "cmp_func"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
681 {"border_mask", NULL, OFFSET(border_masking), FF_OPT_TYPE_FLOAT, DEFAULT, -FLT_MAX, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
682 {"mblmin", "min macroblock quantizer scale (VBR)", OFFSET(mb_lmin), FF_OPT_TYPE_INT, FF_QP2LAMBDA * 2, 1, FF_LAMBDA_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
683 {"mblmax", "max macroblock quantizer scale (VBR)", OFFSET(mb_lmax), FF_OPT_TYPE_INT, FF_QP2LAMBDA * 31, 1, FF_LAMBDA_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
684 {"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), FF_OPT_TYPE_INT, 256, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
685 {"bidir_refine", NULL, OFFSET(bidir_refine), FF_OPT_TYPE_INT, DEFAULT, 0, 4, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
686 {"brd_scale", NULL, OFFSET(brd_scale), FF_OPT_TYPE_INT, DEFAULT, 0, 10, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
687 {"crf", NULL, OFFSET(crf), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
688 {"cqp", NULL, OFFSET(cqp), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
689 {"keyint_min", NULL, OFFSET(keyint_min), FF_OPT_TYPE_INT, 25, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
690 {"refs", NULL, OFFSET(refs), FF_OPT_TYPE_INT, 1, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
691 {"chromaoffset", NULL, OFFSET(chromaoffset), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
692 {"bframebias", NULL, OFFSET(bframebias), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
693 {"trellis", NULL, OFFSET(trellis), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
694 {"directpred", NULL, OFFSET(directpred), FF_OPT_TYPE_INT, 2, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
695 {"bpyramid", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BPYRAMID, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
696 {"wpred", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_WPRED, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
697 {"mixed_refs", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MIXED_REFS, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
698 {"8x8dct", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_8X8DCT, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
699 {"fastpskip", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_FASTPSKIP, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
700 {"aud", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_AUD, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
701 {"brdo", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BRDO, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
702 {"complexityblur", NULL, OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, 20.0, FLT_MIN, FLT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
703 {"deblockalpha", NULL, OFFSET(deblockalpha), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
704 {"deblockbeta", NULL, OFFSET(deblockbeta), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
705 {"partitions", NULL, OFFSET(partitions), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|E, "partitions"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
706 {"parti4x4", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_I4X4, INT_MIN, INT_MAX, V|E, "partitions"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
707 {"parti8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_I8X8, INT_MIN, INT_MAX, V|E, "partitions"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
708 {"partp4x4", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_P4X4, INT_MIN, INT_MAX, V|E, "partitions"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
709 {"partp8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_P8X8, INT_MIN, INT_MAX, V|E, "partitions"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
710 {"partb8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_B8X8, INT_MIN, INT_MAX, V|E, "partitions"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
711 {"sc_factor", NULL, OFFSET(scenechange_factor), FF_OPT_TYPE_INT, 6, 0, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
712 {"mv0_threshold", NULL, OFFSET(mv0_threshold), FF_OPT_TYPE_INT, 256, 0, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
713 {"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
714 {"b_sensitivity", NULL, OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
715 {"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, FF_COMPRESSION_DEFAULT, INT_MIN, INT_MAX, V|A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
716 {"use_lpc", NULL, OFFSET(use_lpc), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
717 {"lpc_coeff_precision", NULL, OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
718 {"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
719 {"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
720 {"prediction_order_method", NULL, OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
721 {"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
722 {"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
723 {NULL},
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
724 };
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
725
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
726 #undef A
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
727 #undef V
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
728 #undef S
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
729 #undef E
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
730 #undef D
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
731 #undef DEFAULT
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
732
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
733 static AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
734
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
735 void avcodec_get_context_defaults(AVCodecContext *s){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
736 memset(s, 0, sizeof(AVCodecContext));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
737
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
738 s->av_class= &av_codec_context_class;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
739
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
740 av_opt_set_defaults(s);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
741
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
742 s->rc_eq= "tex^qComp";
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
743 s->time_base= (AVRational){0,1};
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
744 s->get_buffer= avcodec_default_get_buffer;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
745 s->release_buffer= avcodec_default_release_buffer;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
746 s->get_format= avcodec_default_get_format;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
747 s->execute= avcodec_default_execute;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
748 s->sample_aspect_ratio= (AVRational){0,1};
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
749 s->pix_fmt= PIX_FMT_NONE;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
750 s->sample_fmt= SAMPLE_FMT_S16; // FIXME: set to NONE
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
751
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
752 s->palctrl = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
753 s->reget_buffer= avcodec_default_reget_buffer;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
754 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
755
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
756 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
757 * allocates a AVCodecContext and set it to defaults.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
758 * this can be deallocated by simply calling free()
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
759 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
760 AVCodecContext *avcodec_alloc_context(void){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
761 AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
762
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
763 if(avctx==NULL) return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
764
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
765 avcodec_get_context_defaults(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
766
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
767 return avctx;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
768 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
769
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
770 void avcodec_get_frame_defaults(AVFrame *pic){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
771 memset(pic, 0, sizeof(AVFrame));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
772
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
773 pic->pts= AV_NOPTS_VALUE;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
774 pic->key_frame= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
775 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
776
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
777 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
778 * allocates a AVPFrame and set it to defaults.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
779 * this can be deallocated by simply calling free()
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
780 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
781 AVFrame *avcodec_alloc_frame(void){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
782 AVFrame *pic= av_malloc(sizeof(AVFrame));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
783
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
784 if(pic==NULL) return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
785
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
786 avcodec_get_frame_defaults(pic);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
787
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
788 return pic;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
789 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
790
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
791 int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
792 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
793 int ret= -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
794
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
795 entangled_thread_counter++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
796 if(entangled_thread_counter != 1){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
797 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
798 goto end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
799 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
800
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
801 if(avctx->codec)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
802 goto end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
803
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
804 if (codec->priv_data_size > 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
805 avctx->priv_data = av_mallocz(codec->priv_data_size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
806 if (!avctx->priv_data)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
807 goto end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
808 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
809 avctx->priv_data = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
810 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
811
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
812 if(avctx->coded_width && avctx->coded_height)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
813 avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
814 else if(avctx->width && avctx->height)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
815 avcodec_set_dimensions(avctx, avctx->width, avctx->height);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
816
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
817 if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height)){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
818 av_freep(&avctx->priv_data);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
819 goto end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
820 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
821
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
822 avctx->codec = codec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
823 avctx->codec_id = codec->id;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
824 avctx->frame_number = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
825 ret = avctx->codec->init(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
826 if (ret < 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
827 av_freep(&avctx->priv_data);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
828 avctx->codec= NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
829 goto end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
830 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
831 ret=0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
832 end:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
833 entangled_thread_counter--;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
834 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
835 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
836
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
837 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
838 const short *samples)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
839 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
840 if(buf_size < FF_MIN_BUFFER_SIZE && 0){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
841 av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
842 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
843 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
844 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
845 int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
846 avctx->frame_number++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
847 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
848 }else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
849 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
850 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
851
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
852 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
853 const AVFrame *pict)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
854 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
855 if(buf_size < FF_MIN_BUFFER_SIZE){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
856 av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
857 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
858 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
859 if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
860 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
861 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
862 int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
863 avctx->frame_number++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
864 emms_c(); //needed to avoid an emms_c() call before every return;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
865
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
866 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
867 }else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
868 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
869 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
870
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
871 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
872 const AVSubtitle *sub)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
873 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
874 int ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
875 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
876 avctx->frame_number++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
877 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
878 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
879
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
880 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
881 * decode a frame.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
882 * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
883 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
884 * @param buf_size the size of the buffer in bytes
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
885 * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
886 * @return -1 if error, otherwise return the number of
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
887 * bytes used.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
888 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
889 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
890 int *got_picture_ptr,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
891 uint8_t *buf, int buf_size)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
892 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
893 int ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
894
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
895 *got_picture_ptr= 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
896 if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
897 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
898 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
899 ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
900 buf, buf_size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
901
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
902 emms_c(); //needed to avoid an emms_c() call before every return;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
903
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
904 if (*got_picture_ptr)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
905 avctx->frame_number++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
906 }else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
907 ret= 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
908
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
909 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
910 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
911
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
912 /* decode an audio frame. return -1 if error, otherwise return the
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
913 *number of bytes used. If no frame could be decompressed,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
914 *frame_size_ptr is zero. Otherwise, it is the decompressed frame
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
915 *size in BYTES. */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
916 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
917 int *frame_size_ptr,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
918 uint8_t *buf, int buf_size)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
919 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
920 int ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
921
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
922 *frame_size_ptr= 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
923 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
924 ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
925 buf, buf_size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
926 avctx->frame_number++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
927 }else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
928 ret= 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
929 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
930 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
931
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
932 /* decode a subtitle message. return -1 if error, otherwise return the
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
933 *number of bytes used. If no subtitle could be decompressed,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
934 *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
935 int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
936 int *got_sub_ptr,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
937 const uint8_t *buf, int buf_size)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
938 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
939 int ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
940
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
941 *got_sub_ptr = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
942 ret = avctx->codec->decode(avctx, sub, got_sub_ptr,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
943 (uint8_t *)buf, buf_size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
944 if (*got_sub_ptr)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
945 avctx->frame_number++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
946 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
947 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
948
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
949 int avcodec_close(AVCodecContext *avctx)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
950 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
951 entangled_thread_counter++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
952 if(entangled_thread_counter != 1){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
953 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
954 entangled_thread_counter--;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
955 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
956 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
957
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
958 if (avctx->codec->close)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
959 avctx->codec->close(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
960 avcodec_default_free_buffers(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
961 av_freep(&avctx->priv_data);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
962 avctx->codec = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
963 entangled_thread_counter--;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
964 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
965 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
966
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
967 AVCodec *avcodec_find_encoder(enum CodecID id)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
968 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
969 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
970 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
971 while (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
972 if (p->encode != NULL && p->id == id)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
973 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
974 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
975 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
976 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
977 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
978
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
979 AVCodec *avcodec_find_encoder_by_name(const char *name)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
980 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
981 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
982 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
983 while (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
984 if (p->encode != NULL && strcmp(name,p->name) == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
985 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
986 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
987 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
988 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
989 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
990
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
991 AVCodec *avcodec_find_decoder(enum CodecID id)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
992 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
993 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
994 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
995 while (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
996 if (p->decode != NULL && p->id == id)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
997 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
998 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
999 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1000 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1001 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1002
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1003 AVCodec *avcodec_find_decoder_by_name(const char *name)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1004 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1005 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1006 p = first_avcodec;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1007 while (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1008 if (p->decode != NULL && strcmp(name,p->name) == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1009 return p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1010 p = p->next;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1011 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1012 return NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1013 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1014
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1015 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1016 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1017 const char *codec_name;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1018 AVCodec *p;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1019 char buf1[32];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1020 char channels_str[100];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1021 int bitrate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1022
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1023 if (encode)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1024 p = avcodec_find_encoder(enc->codec_id);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1025 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1026 p = avcodec_find_decoder(enc->codec_id);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1027
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1028 if (p) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1029 codec_name = p->name;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1030 if (!encode && enc->codec_id == CODEC_ID_MP3) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1031 if (enc->sub_id == 2)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1032 codec_name = "mp2";
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1033 else if (enc->sub_id == 1)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1034 codec_name = "mp1";
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1035 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1036 } else if (enc->codec_id == CODEC_ID_MPEG2TS) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1037 /* fake mpeg2 transport stream codec (currently not
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1038 registered) */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1039 codec_name = "mpeg2ts";
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1040 } else if (enc->codec_name[0] != '\0') {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1041 codec_name = enc->codec_name;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1042 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1043 /* output avi tags */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1044 if( isprint(enc->codec_tag&0xFF) && isprint((enc->codec_tag>>8)&0xFF)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1045 && isprint((enc->codec_tag>>16)&0xFF) && isprint((enc->codec_tag>>24)&0xFF)){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1046 snprintf(buf1, sizeof(buf1), "%c%c%c%c / 0x%04X",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1047 enc->codec_tag & 0xff,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1048 (enc->codec_tag >> 8) & 0xff,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1049 (enc->codec_tag >> 16) & 0xff,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1050 (enc->codec_tag >> 24) & 0xff,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1051 enc->codec_tag);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1052 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1053 snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1054 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1055 codec_name = buf1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1056 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1057
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1058 switch(enc->codec_type) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1059 case CODEC_TYPE_VIDEO:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1060 snprintf(buf, buf_size,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1061 "Video: %s%s",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1062 codec_name, enc->mb_decision ? " (hq)" : "");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1063 if (enc->pix_fmt != PIX_FMT_NONE) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1064 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1065 ", %s",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1066 avcodec_get_pix_fmt_name(enc->pix_fmt));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1067 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1068 if (enc->width) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1069 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1070 ", %dx%d",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1071 enc->width, enc->height);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1072 if(av_log_get_level() >= AV_LOG_DEBUG){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1073 int g= ff_gcd(enc->time_base.num, enc->time_base.den);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1074 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1075 ", %d/%d",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1076 enc->time_base.num/g, enc->time_base.den/g);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1077 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1078 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1079 if (encode) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1080 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1081 ", q=%d-%d", enc->qmin, enc->qmax);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1082 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1083 bitrate = enc->bit_rate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1084 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1085 case CODEC_TYPE_AUDIO:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1086 snprintf(buf, buf_size,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1087 "Audio: %s",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1088 codec_name);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1089 switch (enc->channels) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1090 case 1:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1091 strcpy(channels_str, "mono");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1092 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1093 case 2:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1094 strcpy(channels_str, "stereo");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1095 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1096 case 6:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1097 strcpy(channels_str, "5:1");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1098 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1099 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1100 snprintf(channels_str, sizeof(channels_str), "%d channels", enc->channels);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1101 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1102 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1103 if (enc->sample_rate) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1104 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1105 ", %d Hz, %s",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1106 enc->sample_rate,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1107 channels_str);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1108 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1109
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1110 /* for PCM codecs, compute bitrate directly */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1111 switch(enc->codec_id) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1112 case CODEC_ID_PCM_S32LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1113 case CODEC_ID_PCM_S32BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1114 case CODEC_ID_PCM_U32LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1115 case CODEC_ID_PCM_U32BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1116 bitrate = enc->sample_rate * enc->channels * 32;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1117 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1118 case CODEC_ID_PCM_S24LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1119 case CODEC_ID_PCM_S24BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1120 case CODEC_ID_PCM_U24LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1121 case CODEC_ID_PCM_U24BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1122 case CODEC_ID_PCM_S24DAUD:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1123 bitrate = enc->sample_rate * enc->channels * 24;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1124 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1125 case CODEC_ID_PCM_S16LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1126 case CODEC_ID_PCM_S16BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1127 case CODEC_ID_PCM_U16LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1128 case CODEC_ID_PCM_U16BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1129 bitrate = enc->sample_rate * enc->channels * 16;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1130 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1131 case CODEC_ID_PCM_S8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1132 case CODEC_ID_PCM_U8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1133 case CODEC_ID_PCM_ALAW:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1134 case CODEC_ID_PCM_MULAW:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1135 bitrate = enc->sample_rate * enc->channels * 8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1136 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1137 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1138 bitrate = enc->bit_rate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1139 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1140 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1141 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1142 case CODEC_TYPE_DATA:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1143 snprintf(buf, buf_size, "Data: %s", codec_name);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1144 bitrate = enc->bit_rate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1145 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1146 case CODEC_TYPE_SUBTITLE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1147 snprintf(buf, buf_size, "Subtitle: %s", codec_name);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1148 bitrate = enc->bit_rate;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1149 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1150 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1151 snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1152 return;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1153 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1154 if (encode) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1155 if (enc->flags & CODEC_FLAG_PASS1)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1156 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1157 ", pass 1");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1158 if (enc->flags & CODEC_FLAG_PASS2)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1159 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1160 ", pass 2");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1161 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1162 if (bitrate != 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1163 snprintf(buf + strlen(buf), buf_size - strlen(buf),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1164 ", %d kb/s", bitrate / 1000);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1165 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1166 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1167
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1168 unsigned avcodec_version( void )
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1169 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1170 return LIBAVCODEC_VERSION_INT;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1171 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1172
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1173 unsigned avcodec_build( void )
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1174 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1175 return LIBAVCODEC_BUILD;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1176 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1177
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1178 static void init_crcs(void){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1179 av_crc04C11DB7= av_mallocz_static(sizeof(AVCRC) * 257);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1180 av_crc8005 = av_mallocz_static(sizeof(AVCRC) * 257);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1181 av_crc07 = av_mallocz_static(sizeof(AVCRC) * 257);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1182 av_crc_init(av_crc04C11DB7, 0, 32, 0x04c11db7, sizeof(AVCRC)*257);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1183 av_crc_init(av_crc8005 , 0, 16, 0x8005 , sizeof(AVCRC)*257);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1184 av_crc_init(av_crc07 , 0, 8, 0x07 , sizeof(AVCRC)*257);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1185 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1186
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1187 /* must be called before any other functions */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1188 void avcodec_init(void)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1189 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1190 static int inited = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1191
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1192 if (inited != 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1193 return;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1194 inited = 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1195
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1196 dsputil_static_init();
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1197 init_crcs();
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1198 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1199
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1200 /**
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1201 * Flush buffers, should be called when seeking or when swicthing to a different stream.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1202 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1203 void avcodec_flush_buffers(AVCodecContext *avctx)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1204 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1205 if(avctx->codec->flush)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1206 avctx->codec->flush(avctx);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1207 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1208
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1209 void avcodec_default_free_buffers(AVCodecContext *s){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1210 int i, j;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1211
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1212 if(s->internal_buffer==NULL) return;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1213
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1214 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1215 InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1216 for(j=0; j<4; j++){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1217 av_freep(&buf->base[j]);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1218 buf->data[j]= NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1219 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1220 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1221 av_freep(&s->internal_buffer);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1222
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1223 s->internal_buffer_count=0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1224 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1225
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1226 char av_get_pict_type_char(int pict_type){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1227 switch(pict_type){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1228 case I_TYPE: return 'I';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1229 case P_TYPE: return 'P';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1230 case B_TYPE: return 'B';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1231 case S_TYPE: return 'S';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1232 case SI_TYPE:return 'i';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1233 case SP_TYPE:return 'p';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1234 default: return '?';
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1235 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1236 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1237
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1238 int av_get_bits_per_sample(enum CodecID codec_id){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1239 switch(codec_id){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1240 case CODEC_ID_ADPCM_SBPRO_2:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1241 return 2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1242 case CODEC_ID_ADPCM_SBPRO_3:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1243 return 3;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1244 case CODEC_ID_ADPCM_SBPRO_4:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1245 case CODEC_ID_ADPCM_CT:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1246 return 4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1247 case CODEC_ID_PCM_ALAW:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1248 case CODEC_ID_PCM_MULAW:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1249 case CODEC_ID_PCM_S8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1250 case CODEC_ID_PCM_U8:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1251 return 8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1252 case CODEC_ID_PCM_S16BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1253 case CODEC_ID_PCM_S16LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1254 case CODEC_ID_PCM_U16BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1255 case CODEC_ID_PCM_U16LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1256 return 16;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1257 case CODEC_ID_PCM_S24DAUD:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1258 case CODEC_ID_PCM_S24BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1259 case CODEC_ID_PCM_S24LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1260 case CODEC_ID_PCM_U24BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1261 case CODEC_ID_PCM_U24LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1262 return 24;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1263 case CODEC_ID_PCM_S32BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1264 case CODEC_ID_PCM_S32LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1265 case CODEC_ID_PCM_U32BE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1266 case CODEC_ID_PCM_U32LE:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1267 return 32;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1268 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1269 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1270 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1271 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1272
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1273 #if !defined(HAVE_THREADS)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1274 int avcodec_thread_init(AVCodecContext *s, int thread_count){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1275 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1276 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1277 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1278
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1279 unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1280 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1281 unsigned int n = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1282
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1283 while(v >= 0xff) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1284 *s++ = 0xff;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1285 v -= 0xff;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1286 n++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1287 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1288 *s = v;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1289 n++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1290 return n;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1291 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1292
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1293 /* Wrapper to work around the lack of mkstemp() on mingw/cygin.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1294 * Also, tries to create file in /tmp first, if possible.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1295 * *prefix can be a character constant; *filename will be allocated internally.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1296 * Returns file descriptor of opened file (or -1 on error)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1297 * and opened file name in **filename. */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1298 int av_tempfile(char *prefix, char **filename) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1299 int fd=-1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1300 #ifdef __MINGW32__
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1301 *filename = tempnam(".", prefix);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1302 #else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1303 size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1304 *filename = av_malloc(len);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1305 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1306 /* -----common section-----*/
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1307 if (*filename == NULL) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1308 av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1309 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1310 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1311 #ifdef __MINGW32__
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1312 fd = open(*filename, _O_RDWR | _O_BINARY | _O_CREAT, 0444);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1313 #else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1314 snprintf(*filename, len, "/tmp/%sXXXXXX", prefix);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1315 fd = mkstemp(*filename);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1316 if (fd < 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1317 snprintf(*filename, len, "./%sXXXXXX", prefix);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1318 fd = mkstemp(*filename);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1319 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1320 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1321 /* -----common section-----*/
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1322 if (fd < 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1323 av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1324 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1325 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1326 return fd; /* success */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1327 }