Mercurial > libavcodec.hg
annotate utils.c @ 814:8f31ed5bacd1 libavcodec
dont call emms_c() for each MB
| author | michaelni |
|---|---|
| date | Thu, 31 Oct 2002 12:11:53 +0000 |
| parents | 5da504c8c90e |
| children | a25aed263097 |
| rev | line source |
|---|---|
| 0 | 1 /* |
| 2 * utils for libavcodec | |
| 429 | 3 * Copyright (c) 2001 Fabrice Bellard. |
| 0 | 4 * |
| 429 | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Lesser General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 0 | 9 * |
| 429 | 10 * This library is distributed in the hope that it will be useful, |
| 0 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Lesser General Public License for more details. | |
| 0 | 14 * |
| 429 | 15 * You should have received a copy of the GNU Lesser General Public |
| 16 * License along with this library; if not, write to the Free Software | |
| 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 0 | 18 */ |
| 394 | 19 #include "avcodec.h" |
| 0 | 20 #include "dsputil.h" |
| 341 | 21 #include "mpegvideo.h" |
| 0 | 22 |
| 394 | 23 void *av_mallocz(int size) |
| 24 { | |
| 25 void *ptr; | |
| 26 ptr = av_malloc(size); | |
| 27 if (!ptr) | |
| 28 return NULL; | |
| 29 memset(ptr, 0, size); | |
| 30 return ptr; | |
| 31 } | |
| 32 | |
| 400 | 33 /* cannot call it directly because of 'void **' casting is not automatic */ |
| 34 void __av_freep(void **ptr) | |
| 35 { | |
| 36 av_free(*ptr); | |
| 37 *ptr = NULL; | |
| 38 } | |
| 39 | |
| 0 | 40 /* encoder management */ |
| 41 AVCodec *first_avcodec; | |
| 42 | |
| 43 void register_avcodec(AVCodec *format) | |
| 44 { | |
| 45 AVCodec **p; | |
| 46 p = &first_avcodec; | |
| 47 while (*p != NULL) p = &(*p)->next; | |
| 48 *p = format; | |
| 49 format->next = NULL; | |
| 50 } | |
| 51 | |
| 681 | 52 void avcodec_get_context_defaults(AVCodecContext *s){ |
| 685 | 53 s->bit_rate= 800*1000; |
| 54 s->bit_rate_tolerance= s->bit_rate*10; | |
| 681 | 55 s->qmin= 2; |
| 56 s->qmax= 31; | |
| 57 s->rc_eq= "tex^qComp"; | |
| 58 s->qcompress= 0.5; | |
| 685 | 59 s->max_qdiff= 3; |
| 60 s->b_quant_factor=1.25; | |
| 61 s->b_quant_offset=1.25; | |
|
686
83d2c9d50d7d
fixing i_quant_factor, this should finally fix the bitrate bug with ffserver hopefully
michaelni
parents:
685
diff
changeset
|
62 s->i_quant_factor=-0.8; |
| 685 | 63 s->i_quant_offset=0.0; |
|
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
742
diff
changeset
|
64 s->error_concealment= 3; |
| 762 | 65 s->error_resilience= 1; |
|
745
25d7fb7c89be
better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents:
742
diff
changeset
|
66 s->workaround_bugs= FF_BUG_AUTODETECT; |
| 762 | 67 s->frame_rate = 25 * FRAME_RATE_BASE; |
| 68 s->gop_size= 50; | |
| 69 s->me_method= ME_EPZS; | |
| 681 | 70 } |
| 71 | |
| 72 /** | |
| 73 * allocates a AVCodecContext and set it to defaults. | |
| 74 * this can be deallocated by simply calling free() | |
| 75 */ | |
| 703 | 76 AVCodecContext *avcodec_alloc_context(void){ |
| 681 | 77 AVCodecContext *avctx= av_mallocz(sizeof(AVCodecContext)); |
| 78 | |
| 79 if(avctx==NULL) return NULL; | |
| 80 | |
| 81 avcodec_get_context_defaults(avctx); | |
| 82 | |
| 83 return avctx; | |
| 84 } | |
| 85 | |
| 0 | 86 int avcodec_open(AVCodecContext *avctx, AVCodec *codec) |
| 87 { | |
| 88 int ret; | |
| 89 | |
| 90 avctx->codec = codec; | |
| 91 avctx->frame_number = 0; | |
|
374
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
92 if (codec->priv_data_size > 0) { |
|
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
93 avctx->priv_data = av_mallocz(codec->priv_data_size); |
|
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
94 if (!avctx->priv_data) |
|
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
95 return -ENOMEM; |
|
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
96 } else { |
|
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
97 avctx->priv_data = NULL; |
|
02147e22f8c8
* Don't allocate 0 bytes of memory. It upsets electricFence!
philipjsg
parents:
362
diff
changeset
|
98 } |
| 0 | 99 ret = avctx->codec->init(avctx); |
| 100 if (ret < 0) { | |
| 394 | 101 av_freep(&avctx->priv_data); |
| 0 | 102 return ret; |
| 103 } | |
| 104 return 0; | |
| 105 } | |
| 106 | |
| 107 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
| 108 const short *samples) | |
| 109 { | |
| 110 int ret; | |
| 111 | |
| 112 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples); | |
| 113 avctx->frame_number++; | |
| 114 return ret; | |
| 115 } | |
| 116 | |
| 117 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size, | |
| 118 const AVPicture *pict) | |
| 119 { | |
| 120 int ret; | |
| 121 | |
| 122 ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict); | |
| 814 | 123 |
| 124 emms_c(); //needed to avoid a emms_c() call before every return; | |
| 125 | |
| 0 | 126 avctx->frame_number++; |
| 127 return ret; | |
| 128 } | |
| 129 | |
| 130 /* decode a frame. return -1 if error, otherwise return the number of | |
| 131 bytes used. If no frame could be decompressed, *got_picture_ptr is | |
| 132 zero. Otherwise, it is non zero */ | |
| 133 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture, | |
| 134 int *got_picture_ptr, | |
| 135 UINT8 *buf, int buf_size) | |
| 136 { | |
| 137 int ret; | |
| 138 | |
| 139 ret = avctx->codec->decode(avctx, picture, got_picture_ptr, | |
| 140 buf, buf_size); | |
| 814 | 141 |
| 142 emms_c(); //needed to avoid a emms_c() call before every return; | |
| 143 | |
|
267
e10840e4f773
- Bug fix MPEG-2 decoder to handle "repeat_first_field" (Telecine)
pulento
parents:
260
diff
changeset
|
144 if (*got_picture_ptr) |
|
e10840e4f773
- Bug fix MPEG-2 decoder to handle "repeat_first_field" (Telecine)
pulento
parents:
260
diff
changeset
|
145 avctx->frame_number++; |
| 0 | 146 return ret; |
| 147 } | |
| 148 | |
| 149 /* decode an audio frame. return -1 if error, otherwise return the | |
| 150 *number of bytes used. If no frame could be decompressed, | |
| 151 *frame_size_ptr is zero. Otherwise, it is the decompressed frame | |
| 152 *size in BYTES. */ | |
| 153 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, | |
| 154 int *frame_size_ptr, | |
| 155 UINT8 *buf, int buf_size) | |
| 156 { | |
| 157 int ret; | |
| 158 | |
| 159 ret = avctx->codec->decode(avctx, samples, frame_size_ptr, | |
| 160 buf, buf_size); | |
| 161 avctx->frame_number++; | |
| 162 return ret; | |
| 163 } | |
| 164 | |
| 165 int avcodec_close(AVCodecContext *avctx) | |
| 166 { | |
| 167 if (avctx->codec->close) | |
| 168 avctx->codec->close(avctx); | |
| 394 | 169 av_freep(&avctx->priv_data); |
| 0 | 170 avctx->codec = NULL; |
| 171 return 0; | |
| 172 } | |
| 173 | |
| 174 AVCodec *avcodec_find_encoder(enum CodecID id) | |
| 175 { | |
| 176 AVCodec *p; | |
| 177 p = first_avcodec; | |
| 178 while (p) { | |
| 179 if (p->encode != NULL && p->id == id) | |
| 180 return p; | |
| 181 p = p->next; | |
| 182 } | |
| 183 return NULL; | |
| 184 } | |
| 185 | |
| 177 | 186 AVCodec *avcodec_find_encoder_by_name(const char *name) |
| 187 { | |
| 188 AVCodec *p; | |
| 189 p = first_avcodec; | |
| 190 while (p) { | |
| 191 if (p->encode != NULL && strcmp(name,p->name) == 0) | |
| 192 return p; | |
| 193 p = p->next; | |
| 194 } | |
| 195 return NULL; | |
| 196 } | |
| 197 | |
| 0 | 198 AVCodec *avcodec_find_decoder(enum CodecID id) |
| 199 { | |
| 200 AVCodec *p; | |
| 201 p = first_avcodec; | |
| 202 while (p) { | |
| 203 if (p->decode != NULL && p->id == id) | |
| 204 return p; | |
| 205 p = p->next; | |
| 206 } | |
| 207 return NULL; | |
| 208 } | |
| 209 | |
| 210 AVCodec *avcodec_find_decoder_by_name(const char *name) | |
| 211 { | |
| 212 AVCodec *p; | |
| 213 p = first_avcodec; | |
| 214 while (p) { | |
| 215 if (p->decode != NULL && strcmp(name,p->name) == 0) | |
| 216 return p; | |
| 217 p = p->next; | |
| 218 } | |
| 219 return NULL; | |
| 220 } | |
| 221 | |
| 222 AVCodec *avcodec_find(enum CodecID id) | |
| 223 { | |
| 224 AVCodec *p; | |
| 225 p = first_avcodec; | |
| 226 while (p) { | |
| 227 if (p->id == id) | |
| 228 return p; | |
| 229 p = p->next; | |
| 230 } | |
| 231 return NULL; | |
| 232 } | |
| 233 | |
| 55 | 234 const char *pix_fmt_str[] = { |
| 235 "yuv420p", | |
| 236 "yuv422", | |
| 237 "rgb24", | |
| 238 "bgr24", | |
| 239 "yuv422p", | |
| 240 "yuv444p", | |
| 583 | 241 "rgba32", |
| 242 "bgra32", | |
| 742 | 243 "yuv410p", |
| 244 "yuv411p", | |
| 55 | 245 }; |
| 742 | 246 |
| 0 | 247 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) |
| 248 { | |
| 249 const char *codec_name; | |
| 250 AVCodec *p; | |
| 251 char buf1[32]; | |
| 337 | 252 char channels_str[100]; |
| 92 | 253 int bitrate; |
| 0 | 254 |
| 255 if (encode) | |
| 256 p = avcodec_find_encoder(enc->codec_id); | |
| 257 else | |
| 258 p = avcodec_find_decoder(enc->codec_id); | |
| 259 | |
| 260 if (p) { | |
| 261 codec_name = p->name; | |
| 262 } else if (enc->codec_name[0] != '\0') { | |
| 263 codec_name = enc->codec_name; | |
| 264 } else { | |
| 265 /* output avi tags */ | |
| 266 if (enc->codec_type == CODEC_TYPE_VIDEO) { | |
| 267 snprintf(buf1, sizeof(buf1), "%c%c%c%c", | |
| 268 enc->codec_tag & 0xff, | |
| 269 (enc->codec_tag >> 8) & 0xff, | |
| 270 (enc->codec_tag >> 16) & 0xff, | |
| 271 (enc->codec_tag >> 24) & 0xff); | |
| 272 } else { | |
| 273 snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag); | |
| 274 } | |
| 275 codec_name = buf1; | |
| 276 } | |
| 277 | |
| 278 switch(enc->codec_type) { | |
| 279 case CODEC_TYPE_VIDEO: | |
| 280 snprintf(buf, buf_size, | |
| 281 "Video: %s%s", | |
| 282 codec_name, enc->flags & CODEC_FLAG_HQ ? " (hq)" : ""); | |
| 55 | 283 if (enc->codec_id == CODEC_ID_RAWVIDEO) { |
| 284 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
| 285 ", %s", | |
| 286 pix_fmt_str[enc->pix_fmt]); | |
| 287 } | |
| 0 | 288 if (enc->width) { |
| 289 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
| 290 ", %dx%d, %0.2f fps", | |
| 291 enc->width, enc->height, | |
| 292 (float)enc->frame_rate / FRAME_RATE_BASE); | |
| 293 } | |
| 741 | 294 if (encode) { |
| 295 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
| 296 ", q=%d-%d", enc->qmin, enc->qmax); | |
| 297 } | |
| 92 | 298 bitrate = enc->bit_rate; |
| 0 | 299 break; |
| 300 case CODEC_TYPE_AUDIO: | |
| 301 snprintf(buf, buf_size, | |
| 302 "Audio: %s", | |
| 303 codec_name); | |
|
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
304 switch (enc->channels) { |
|
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
305 case 1: |
| 337 | 306 strcpy(channels_str, "mono"); |
|
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
307 break; |
|
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
308 case 2: |
| 337 | 309 strcpy(channels_str, "stereo"); |
|
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
310 break; |
|
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
311 case 6: |
| 337 | 312 strcpy(channels_str, "5:1"); |
|
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
313 break; |
|
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
314 default: |
|
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
315 sprintf(channels_str, "%d channels", enc->channels); |
|
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
316 break; |
|
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
317 } |
| 0 | 318 if (enc->sample_rate) { |
| 319 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
| 320 ", %d Hz, %s", | |
| 321 enc->sample_rate, | |
|
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
322 channels_str); |
| 0 | 323 } |
|
318
21697f35a9ca
- Fixed AC3 decoding for 5:1 AC3 streams. Now when calling av_audio_decode for
pulento
parents:
315
diff
changeset
|
324 |
| 92 | 325 /* for PCM codecs, compute bitrate directly */ |
| 326 switch(enc->codec_id) { | |
| 327 case CODEC_ID_PCM_S16LE: | |
| 328 case CODEC_ID_PCM_S16BE: | |
| 329 case CODEC_ID_PCM_U16LE: | |
| 330 case CODEC_ID_PCM_U16BE: | |
| 94 | 331 bitrate = enc->sample_rate * enc->channels * 16; |
| 92 | 332 break; |
| 333 case CODEC_ID_PCM_S8: | |
| 334 case CODEC_ID_PCM_U8: | |
| 335 case CODEC_ID_PCM_ALAW: | |
| 336 case CODEC_ID_PCM_MULAW: | |
| 94 | 337 bitrate = enc->sample_rate * enc->channels * 8; |
| 92 | 338 break; |
| 339 default: | |
| 340 bitrate = enc->bit_rate; | |
| 341 break; | |
| 342 } | |
| 0 | 343 break; |
| 344 default: | |
| 583 | 345 av_abort(); |
| 0 | 346 } |
| 741 | 347 if (encode) { |
| 348 if (enc->flags & CODEC_FLAG_PASS1) | |
| 349 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
| 350 ", pass 1"); | |
| 351 if (enc->flags & CODEC_FLAG_PASS2) | |
| 352 snprintf(buf + strlen(buf), buf_size - strlen(buf), | |
| 353 ", pass 2"); | |
| 354 } | |
| 92 | 355 if (bitrate != 0) { |
| 0 | 356 snprintf(buf + strlen(buf), buf_size - strlen(buf), |
| 92 | 357 ", %d kb/s", bitrate / 1000); |
| 0 | 358 } |
| 359 } | |
| 360 | |
| 55 | 361 /* Picture field are filled with 'ptr' addresses */ |
| 362 void avpicture_fill(AVPicture *picture, UINT8 *ptr, | |
| 363 int pix_fmt, int width, int height) | |
| 364 { | |
| 365 int size; | |
| 366 | |
| 367 size = width * height; | |
| 368 switch(pix_fmt) { | |
| 369 case PIX_FMT_YUV420P: | |
| 370 picture->data[0] = ptr; | |
| 371 picture->data[1] = picture->data[0] + size; | |
| 372 picture->data[2] = picture->data[1] + size / 4; | |
| 373 picture->linesize[0] = width; | |
| 374 picture->linesize[1] = width / 2; | |
| 375 picture->linesize[2] = width / 2; | |
| 376 break; | |
| 377 case PIX_FMT_YUV422P: | |
| 378 picture->data[0] = ptr; | |
| 379 picture->data[1] = picture->data[0] + size; | |
| 380 picture->data[2] = picture->data[1] + size / 2; | |
| 381 picture->linesize[0] = width; | |
| 382 picture->linesize[1] = width / 2; | |
| 383 picture->linesize[2] = width / 2; | |
| 384 break; | |
| 385 case PIX_FMT_YUV444P: | |
| 386 picture->data[0] = ptr; | |
| 387 picture->data[1] = picture->data[0] + size; | |
| 388 picture->data[2] = picture->data[1] + size; | |
| 389 picture->linesize[0] = width; | |
| 390 picture->linesize[1] = width; | |
| 391 picture->linesize[2] = width; | |
| 392 break; | |
| 393 case PIX_FMT_RGB24: | |
| 394 case PIX_FMT_BGR24: | |
| 395 picture->data[0] = ptr; | |
| 396 picture->data[1] = NULL; | |
| 397 picture->data[2] = NULL; | |
| 398 picture->linesize[0] = width * 3; | |
| 399 break; | |
| 583 | 400 case PIX_FMT_RGBA32: |
| 401 case PIX_FMT_BGRA32: | |
| 402 picture->data[0] = ptr; | |
| 403 picture->data[1] = NULL; | |
| 404 picture->data[2] = NULL; | |
| 405 picture->linesize[0] = width * 4; | |
| 406 break; | |
| 55 | 407 case PIX_FMT_YUV422: |
| 408 picture->data[0] = ptr; | |
| 409 picture->data[1] = NULL; | |
| 410 picture->data[2] = NULL; | |
| 411 picture->linesize[0] = width * 2; | |
| 412 break; | |
| 413 default: | |
| 414 picture->data[0] = NULL; | |
| 415 picture->data[1] = NULL; | |
| 416 picture->data[2] = NULL; | |
| 417 break; | |
| 418 } | |
| 419 } | |
| 420 | |
| 421 int avpicture_get_size(int pix_fmt, int width, int height) | |
| 422 { | |
| 423 int size; | |
| 424 | |
| 425 size = width * height; | |
| 426 switch(pix_fmt) { | |
| 427 case PIX_FMT_YUV420P: | |
| 428 size = (size * 3) / 2; | |
| 429 break; | |
| 430 case PIX_FMT_YUV422P: | |
| 431 size = (size * 2); | |
| 432 break; | |
| 433 case PIX_FMT_YUV444P: | |
| 434 size = (size * 3); | |
| 435 break; | |
| 436 case PIX_FMT_RGB24: | |
| 437 case PIX_FMT_BGR24: | |
| 438 size = (size * 3); | |
| 439 break; | |
| 583 | 440 case PIX_FMT_RGBA32: |
| 441 case PIX_FMT_BGRA32: | |
| 442 size = (size * 4); | |
| 443 break; | |
| 55 | 444 case PIX_FMT_YUV422: |
| 445 size = (size * 2); | |
| 446 break; | |
| 447 default: | |
| 448 size = -1; | |
| 449 break; | |
| 450 } | |
| 451 return size; | |
| 452 } | |
| 453 | |
| 362 | 454 unsigned avcodec_version( void ) |
| 455 { | |
| 456 return LIBAVCODEC_VERSION_INT; | |
| 457 } | |
| 55 | 458 |
| 379 | 459 unsigned avcodec_build( void ) |
| 460 { | |
| 461 return LIBAVCODEC_BUILD; | |
| 462 } | |
| 463 | |
| 0 | 464 /* must be called before any other functions */ |
| 465 void avcodec_init(void) | |
| 466 { | |
|
303
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
467 static int inited = 0; |
|
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
468 |
|
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
469 if (inited != 0) |
|
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
470 return; |
|
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
471 inited = 1; |
|
9a931fd8d06c
multiple init bugfix (patch by Alex Beregszaszi <alex@naxine.org>)
michaelni
parents:
267
diff
changeset
|
472 |
| 0 | 473 dsputil_init(); |
| 474 } | |
| 475 | |
| 341 | 476 /* this should be called after seeking and before trying to decode the next frame */ |
| 477 void avcodec_flush_buffers(AVCodecContext *avctx) | |
| 478 { | |
| 479 MpegEncContext *s = avctx->priv_data; | |
| 480 s->num_available_buffers=0; | |
| 481 } | |
| 482 | |
| 483 | |
|
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
484 static int raw_encode_init(AVCodecContext *s) |
| 0 | 485 { |
| 486 return 0; | |
| 487 } | |
| 488 | |
|
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
489 static int raw_decode_frame(AVCodecContext *avctx, |
|
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
490 void *data, int *data_size, |
|
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
491 UINT8 *buf, int buf_size) |
| 0 | 492 { |
| 493 return -1; | |
| 494 } | |
| 495 | |
|
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
496 static int raw_encode_frame(AVCodecContext *avctx, |
|
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
497 unsigned char *frame, int buf_size, void *data) |
| 0 | 498 { |
| 499 return -1; | |
| 500 } | |
| 501 | |
| 502 AVCodec rawvideo_codec = { | |
| 503 "rawvideo", | |
| 504 CODEC_TYPE_VIDEO, | |
| 505 CODEC_ID_RAWVIDEO, | |
| 506 0, | |
|
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
507 raw_encode_init, |
|
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
508 raw_encode_frame, |
| 0 | 509 NULL, |
|
440
000aeeac27a2
* started to cleanup name clashes for onetime compilation
kabi
parents:
429
diff
changeset
|
510 raw_decode_frame, |
| 0 | 511 }; |
