00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #include "libavutil/avstring.h"
00029 #include "libavutil/integer.h"
00030 #include "libavutil/crc.h"
00031 #include "libavutil/pixdesc.h"
00032 #include "libavutil/audioconvert.h"
00033 #include "libavutil/imgutils.h"
00034 #include "libavutil/samplefmt.h"
00035 #include "avcodec.h"
00036 #include "dsputil.h"
00037 #include "libavutil/opt.h"
00038 #include "imgconvert.h"
00039 #include "thread.h"
00040 #include "audioconvert.h"
00041 #include "internal.h"
00042 #include <stdlib.h>
00043 #include <stdarg.h>
00044 #include <limits.h>
00045 #include <float.h>
00046
00047 static int volatile entangled_thread_counter=0;
00048 static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op);
00049 static void *codec_mutex;
00050
00051 void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size)
00052 {
00053 if(min_size < *size)
00054 return ptr;
00055
00056 min_size= FFMAX(17*min_size/16 + 32, min_size);
00057
00058 ptr= av_realloc(ptr, min_size);
00059 if(!ptr)
00060 min_size= 0;
00061
00062 *size= min_size;
00063
00064 return ptr;
00065 }
00066
00067 void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size)
00068 {
00069 void **p = ptr;
00070 if (min_size < *size)
00071 return;
00072 min_size= FFMAX(17*min_size/16 + 32, min_size);
00073 av_free(*p);
00074 *p = av_malloc(min_size);
00075 if (!*p) min_size = 0;
00076 *size= min_size;
00077 }
00078
00079
00080 static AVCodec *first_avcodec = NULL;
00081
00082 AVCodec *av_codec_next(AVCodec *c){
00083 if(c) return c->next;
00084 else return first_avcodec;
00085 }
00086
00087 void avcodec_register(AVCodec *codec)
00088 {
00089 AVCodec **p;
00090 avcodec_init();
00091 p = &first_avcodec;
00092 while (*p != NULL) p = &(*p)->next;
00093 *p = codec;
00094 codec->next = NULL;
00095 }
00096
00097 #if LIBAVCODEC_VERSION_MAJOR < 53
00098 void register_avcodec(AVCodec *codec)
00099 {
00100 avcodec_register(codec);
00101 }
00102 #endif
00103
00104 unsigned avcodec_get_edge_width(void)
00105 {
00106 return EDGE_WIDTH;
00107 }
00108
00109 void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
00110 s->coded_width = width;
00111 s->coded_height= height;
00112 s->width = -((-width )>>s->lowres);
00113 s->height= -((-height)>>s->lowres);
00114 }
00115
00116 typedef struct InternalBuffer{
00117 int last_pic_num;
00118 uint8_t *base[4];
00119 uint8_t *data[4];
00120 int linesize[4];
00121 int width, height;
00122 enum PixelFormat pix_fmt;
00123 }InternalBuffer;
00124
00125 #define INTERNAL_BUFFER_SIZE 32
00126
00127 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){
00128 int w_align= 1;
00129 int h_align= 1;
00130
00131 switch(s->pix_fmt){
00132 case PIX_FMT_YUV420P:
00133 case PIX_FMT_YUYV422:
00134 case PIX_FMT_UYVY422:
00135 case PIX_FMT_YUV422P:
00136 case PIX_FMT_YUV440P:
00137 case PIX_FMT_YUV444P:
00138 case PIX_FMT_GRAY8:
00139 case PIX_FMT_GRAY16BE:
00140 case PIX_FMT_GRAY16LE:
00141 case PIX_FMT_YUVJ420P:
00142 case PIX_FMT_YUVJ422P:
00143 case PIX_FMT_YUVJ440P:
00144 case PIX_FMT_YUVJ444P:
00145 case PIX_FMT_YUVA420P:
00146 w_align= 16;
00147 h_align= 16;
00148 if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264)
00149 h_align= 32;
00150 break;
00151 case PIX_FMT_YUV411P:
00152 case PIX_FMT_UYYVYY411:
00153 w_align=32;
00154 h_align=8;
00155 break;
00156 case PIX_FMT_YUV410P:
00157 if(s->codec_id == CODEC_ID_SVQ1){
00158 w_align=64;
00159 h_align=64;
00160 }
00161 case PIX_FMT_RGB555:
00162 if(s->codec_id == CODEC_ID_RPZA){
00163 w_align=4;
00164 h_align=4;
00165 }
00166 case PIX_FMT_PAL8:
00167 case PIX_FMT_BGR8:
00168 case PIX_FMT_RGB8:
00169 if(s->codec_id == CODEC_ID_SMC){
00170 w_align=4;
00171 h_align=4;
00172 }
00173 break;
00174 case PIX_FMT_BGR24:
00175 if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){
00176 w_align=4;
00177 h_align=4;
00178 }
00179 break;
00180 default:
00181 w_align= 1;
00182 h_align= 1;
00183 break;
00184 }
00185
00186 *width = FFALIGN(*width , w_align);
00187 *height= FFALIGN(*height, h_align);
00188 if(s->codec_id == CODEC_ID_H264 || s->lowres)
00189 *height+=2;
00190
00191
00192 linesize_align[0] =
00193 linesize_align[1] =
00194 linesize_align[2] =
00195 linesize_align[3] = STRIDE_ALIGN;
00196
00197
00198
00199
00200 #if HAVE_MMX
00201 if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||
00202 s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||
00203 s->codec_id == CODEC_ID_VP6A) {
00204 linesize_align[0] =
00205 linesize_align[1] =
00206 linesize_align[2] = 16;
00207 }
00208 #endif
00209 }
00210
00211 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
00212 int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w;
00213 int linesize_align[4];
00214 int align;
00215 avcodec_align_dimensions2(s, width, height, linesize_align);
00216 align = FFMAX(linesize_align[0], linesize_align[3]);
00217 linesize_align[1] <<= chroma_shift;
00218 linesize_align[2] <<= chroma_shift;
00219 align = FFMAX3(align, linesize_align[1], linesize_align[2]);
00220 *width=FFALIGN(*width, align);
00221 }
00222
00223 #if LIBAVCODEC_VERSION_MAJOR < 53
00224 int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
00225 return av_image_check_size(w, h, 0, av_log_ctx);
00226 }
00227 #endif
00228
00229 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
00230 int i;
00231 int w= s->width;
00232 int h= s->height;
00233 InternalBuffer *buf;
00234 int *picture_number;
00235
00236 if(pic->data[0]!=NULL) {
00237 av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n");
00238 return -1;
00239 }
00240 if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) {
00241 av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n");
00242 return -1;
00243 }
00244
00245 if(av_image_check_size(w, h, 0, s))
00246 return -1;
00247
00248 if(s->internal_buffer==NULL){
00249 s->internal_buffer= av_mallocz((INTERNAL_BUFFER_SIZE+1)*sizeof(InternalBuffer));
00250 }
00251 #if 0
00252 s->internal_buffer= av_fast_realloc(
00253 s->internal_buffer,
00254 &s->internal_buffer_size,
00255 sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1)
00256 );
00257 #endif
00258
00259 buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
00260 picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE]).last_pic_num;
00261 (*picture_number)++;
00262
00263 if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){
00264 if(s->active_thread_type&FF_THREAD_FRAME) {
00265 av_log_missing_feature(s, "Width/height changing with frame threads is", 0);
00266 return -1;
00267 }
00268
00269 for(i=0; i<4; i++){
00270 av_freep(&buf->base[i]);
00271 buf->data[i]= NULL;
00272 }
00273 }
00274
00275 if(buf->base[0]){
00276 pic->age= *picture_number - buf->last_pic_num;
00277 buf->last_pic_num= *picture_number;
00278 }else{
00279 int h_chroma_shift, v_chroma_shift;
00280 int size[4] = {0};
00281 int tmpsize;
00282 int unaligned;
00283 AVPicture picture;
00284 int stride_align[4];
00285
00286 avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
00287
00288 avcodec_align_dimensions2(s, &w, &h, stride_align);
00289
00290 if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
00291 w+= EDGE_WIDTH*2;
00292 h+= EDGE_WIDTH*2;
00293 }
00294
00295 do {
00296
00297
00298 av_image_fill_linesizes(picture.linesize, s->pix_fmt, w);
00299
00300 w += w & ~(w-1);
00301
00302 unaligned = 0;
00303 for (i=0; i<4; i++){
00304 unaligned |= picture.linesize[i] % stride_align[i];
00305 }
00306 } while (unaligned);
00307
00308 tmpsize = av_image_fill_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize);
00309 if (tmpsize < 0)
00310 return -1;
00311
00312 for (i=0; i<3 && picture.data[i+1]; i++)
00313 size[i] = picture.data[i+1] - picture.data[i];
00314 size[i] = tmpsize - (picture.data[i] - picture.data[0]);
00315
00316 buf->last_pic_num= -256*256*256*64;
00317 memset(buf->base, 0, sizeof(buf->base));
00318 memset(buf->data, 0, sizeof(buf->data));
00319
00320 for(i=0; i<4 && size[i]; i++){
00321 const int h_shift= i==0 ? 0 : h_chroma_shift;
00322 const int v_shift= i==0 ? 0 : v_chroma_shift;
00323
00324 buf->linesize[i]= picture.linesize[i];
00325
00326 buf->base[i]= av_malloc(size[i]+16);
00327 if(buf->base[i]==NULL) return -1;
00328 memset(buf->base[i], 128, size[i]);
00329
00330
00331 if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2])
00332 buf->data[i] = buf->base[i];
00333 else
00334 buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]);
00335 }
00336 if(size[1] && !size[2])
00337 ff_set_systematic_pal2((uint32_t*)buf->data[1], s->pix_fmt);
00338 buf->width = s->width;
00339 buf->height = s->height;
00340 buf->pix_fmt= s->pix_fmt;
00341 pic->age= 256*256*256*64;
00342 }
00343 pic->type= FF_BUFFER_TYPE_INTERNAL;
00344
00345 for(i=0; i<4; i++){
00346 pic->base[i]= buf->base[i];
00347 pic->data[i]= buf->data[i];
00348 pic->linesize[i]= buf->linesize[i];
00349 }
00350 s->internal_buffer_count++;
00351
00352 if(s->pkt) pic->pkt_pts= s->pkt->pts;
00353 else pic->pkt_pts= AV_NOPTS_VALUE;
00354 pic->reordered_opaque= s->reordered_opaque;
00355
00356 if(s->debug&FF_DEBUG_BUFFERS)
00357 av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count);
00358
00359 return 0;
00360 }
00361
00362 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
00363 int i;
00364 InternalBuffer *buf, *last;
00365
00366 assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
00367 assert(s->internal_buffer_count);
00368
00369 if(s->internal_buffer){
00370 buf = NULL;
00371 for(i=0; i<s->internal_buffer_count; i++){
00372 buf= &((InternalBuffer*)s->internal_buffer)[i];
00373 if(buf->data[0] == pic->data[0])
00374 break;
00375 }
00376 assert(i < s->internal_buffer_count);
00377 s->internal_buffer_count--;
00378 last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
00379
00380 FFSWAP(InternalBuffer, *buf, *last);
00381 }
00382
00383 for(i=0; i<4; i++){
00384 pic->data[i]=NULL;
00385
00386 }
00387
00388
00389 if(s->debug&FF_DEBUG_BUFFERS)
00390 av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count);
00391 }
00392
00393 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
00394 AVFrame temp_pic;
00395 int i;
00396
00397
00398 if(pic->data[0] == NULL) {
00399
00400 pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
00401 return s->get_buffer(s, pic);
00402 }
00403
00404
00405 if(pic->type == FF_BUFFER_TYPE_INTERNAL) {
00406 if(s->pkt) pic->pkt_pts= s->pkt->pts;
00407 else pic->pkt_pts= AV_NOPTS_VALUE;
00408 pic->reordered_opaque= s->reordered_opaque;
00409 return 0;
00410 }
00411
00412
00413
00414
00415 temp_pic = *pic;
00416 for(i = 0; i < 4; i++)
00417 pic->data[i] = pic->base[i] = NULL;
00418 pic->opaque = NULL;
00419
00420 if (s->get_buffer(s, pic))
00421 return -1;
00422
00423 av_picture_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width,
00424 s->height);
00425 s->release_buffer(s, &temp_pic);
00426 return 0;
00427 }
00428
00429 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){
00430 int i;
00431
00432 for(i=0; i<count; i++){
00433 int r= func(c, (char*)arg + i*size);
00434 if(ret) ret[i]= r;
00435 }
00436 return 0;
00437 }
00438
00439 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr),void *arg, int *ret, int count){
00440 int i;
00441
00442 for(i=0; i<count; i++){
00443 int r= func(c, arg, i, 0);
00444 if(ret) ret[i]= r;
00445 }
00446 return 0;
00447 }
00448
00449 enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt){
00450 while (*fmt != PIX_FMT_NONE && ff_is_hwaccel_pix_fmt(*fmt))
00451 ++fmt;
00452 return fmt[0];
00453 }
00454
00455 void avcodec_get_frame_defaults(AVFrame *pic){
00456 memset(pic, 0, sizeof(AVFrame));
00457
00458 pic->pts = pic->best_effort_timestamp = AV_NOPTS_VALUE;
00459 pic->key_frame= 1;
00460 }
00461
00462 AVFrame *avcodec_alloc_frame(void){
00463 AVFrame *pic= av_malloc(sizeof(AVFrame));
00464
00465 if(pic==NULL) return NULL;
00466
00467 avcodec_get_frame_defaults(pic);
00468
00469 return pic;
00470 }
00471
00472 int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
00473 {
00474 int ret= -1;
00475
00476
00477 if (ff_lockmgr_cb) {
00478 if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
00479 return -1;
00480 }
00481
00482 entangled_thread_counter++;
00483 if(entangled_thread_counter != 1){
00484 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
00485 goto end;
00486 }
00487
00488 if(avctx->codec || !codec)
00489 goto end;
00490
00491 if (codec->priv_data_size > 0) {
00492 if(!avctx->priv_data){
00493 avctx->priv_data = av_mallocz(codec->priv_data_size);
00494 if (!avctx->priv_data) {
00495 ret = AVERROR(ENOMEM);
00496 goto end;
00497 }
00498 if(codec->priv_class){
00499 *(AVClass**)avctx->priv_data= codec->priv_class;
00500 av_opt_set_defaults(avctx->priv_data);
00501 }
00502 }
00503 } else {
00504 avctx->priv_data = NULL;
00505 }
00506
00507 if(avctx->coded_width && avctx->coded_height)
00508 avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
00509 else if(avctx->width && avctx->height)
00510 avcodec_set_dimensions(avctx, avctx->width, avctx->height);
00511
00512 if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
00513 && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
00514 || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
00515 av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n");
00516 avcodec_set_dimensions(avctx, 0, 0);
00517 }
00518
00519
00520
00521 if (codec->decode)
00522 av_freep(&avctx->subtitle_header);
00523
00524 #define SANE_NB_CHANNELS 128U
00525 if (avctx->channels > SANE_NB_CHANNELS) {
00526 ret = AVERROR(EINVAL);
00527 goto free_and_end;
00528 }
00529
00530 avctx->codec = codec;
00531 if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
00532 avctx->codec_id == CODEC_ID_NONE) {
00533 avctx->codec_type = codec->type;
00534 avctx->codec_id = codec->id;
00535 }
00536 if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
00537 && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
00538 av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
00539 goto free_and_end;
00540 }
00541 avctx->frame_number = 0;
00542
00543 if (HAVE_THREADS && !avctx->thread_opaque) {
00544 ret = ff_thread_init(avctx, avctx->thread_count);
00545 if (ret < 0) {
00546 goto free_and_end;
00547 }
00548 }
00549
00550 if (avctx->codec->max_lowres < avctx->lowres) {
00551 av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
00552 avctx->codec->max_lowres);
00553 goto free_and_end;
00554 }
00555 if (avctx->codec->sample_fmts && avctx->codec->encode) {
00556 int i;
00557 for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
00558 if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
00559 break;
00560 if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
00561 av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
00562 goto free_and_end;
00563 }
00564 }
00565
00566 avctx->pts_correction_num_faulty_pts =
00567 avctx->pts_correction_num_faulty_dts = 0;
00568 avctx->pts_correction_last_pts =
00569 avctx->pts_correction_last_dts = INT64_MIN;
00570
00571 if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
00572 ret = avctx->codec->init(avctx);
00573 if (ret < 0) {
00574 goto free_and_end;
00575 }
00576 }
00577
00578 ret=0;
00579 end:
00580 entangled_thread_counter--;
00581
00582
00583 if (ff_lockmgr_cb) {
00584 (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
00585 }
00586 return ret;
00587 free_and_end:
00588 av_freep(&avctx->priv_data);
00589 avctx->codec= NULL;
00590 goto end;
00591 }
00592
00593 int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
00594 const short *samples)
00595 {
00596 if(buf_size < FF_MIN_BUFFER_SIZE && 0){
00597 av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
00598 return -1;
00599 }
00600 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){
00601 int ret = avctx->codec->encode(avctx, buf, buf_size, samples);
00602 avctx->frame_number++;
00603 return ret;
00604 }else
00605 return 0;
00606 }
00607
00608 int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
00609 const AVFrame *pict)
00610 {
00611 if(buf_size < FF_MIN_BUFFER_SIZE){
00612 av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
00613 return -1;
00614 }
00615 if(av_image_check_size(avctx->width, avctx->height, 0, avctx))
00616 return -1;
00617 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
00618 int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
00619 avctx->frame_number++;
00620 emms_c();
00621
00622 return ret;
00623 }else
00624 return 0;
00625 }
00626
00627 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
00628 const AVSubtitle *sub)
00629 {
00630 int ret;
00631 if(sub->start_display_time) {
00632 av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n");
00633 return -1;
00634 }
00635 if(sub->num_rects == 0 || !sub->rects)
00636 return -1;
00637 ret = avctx->codec->encode(avctx, buf, buf_size, sub);
00638 avctx->frame_number++;
00639 return ret;
00640 }
00641
00652 static int64_t guess_correct_pts(AVCodecContext *ctx,
00653 int64_t reordered_pts, int64_t dts)
00654 {
00655 int64_t pts = AV_NOPTS_VALUE;
00656
00657 if (dts != AV_NOPTS_VALUE) {
00658 ctx->pts_correction_num_faulty_dts += dts <= ctx->pts_correction_last_dts;
00659 ctx->pts_correction_last_dts = dts;
00660 }
00661 if (reordered_pts != AV_NOPTS_VALUE) {
00662 ctx->pts_correction_num_faulty_pts += reordered_pts <= ctx->pts_correction_last_pts;
00663 ctx->pts_correction_last_pts = reordered_pts;
00664 }
00665 if ((ctx->pts_correction_num_faulty_pts<=ctx->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE)
00666 && reordered_pts != AV_NOPTS_VALUE)
00667 pts = reordered_pts;
00668 else
00669 pts = dts;
00670
00671 return pts;
00672 }
00673
00674
00675 #if FF_API_VIDEO_OLD
00676 int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
00677 int *got_picture_ptr,
00678 const uint8_t *buf, int buf_size)
00679 {
00680 AVPacket avpkt;
00681 av_init_packet(&avpkt);
00682 avpkt.data = buf;
00683 avpkt.size = buf_size;
00684
00685 avpkt.flags = AV_PKT_FLAG_KEY;
00686
00687 return avcodec_decode_video2(avctx, picture, got_picture_ptr, &avpkt);
00688 }
00689 #endif
00690
00691 int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
00692 int *got_picture_ptr,
00693 AVPacket *avpkt)
00694 {
00695 int ret;
00696
00697 *got_picture_ptr= 0;
00698 if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
00699 return -1;
00700
00701 avctx->pkt = avpkt;
00702
00703 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
00704 if (HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
00705 ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
00706 avpkt);
00707 else {
00708 ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
00709 avpkt);
00710 picture->pkt_dts= avpkt->dts;
00711 }
00712
00713 emms_c();
00714
00715
00716 if (*got_picture_ptr){
00717 avctx->frame_number++;
00718 picture->best_effort_timestamp = guess_correct_pts(avctx,
00719 picture->pkt_pts,
00720 picture->pkt_dts);
00721 }
00722 }else
00723 ret= 0;
00724
00725 return ret;
00726 }
00727
00728 #if FF_API_AUDIO_OLD
00729 int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
00730 int *frame_size_ptr,
00731 const uint8_t *buf, int buf_size)
00732 {
00733 AVPacket avpkt;
00734 av_init_packet(&avpkt);
00735 avpkt.data = buf;
00736 avpkt.size = buf_size;
00737
00738 return avcodec_decode_audio3(avctx, samples, frame_size_ptr, &avpkt);
00739 }
00740 #endif
00741
00742 int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
00743 int *frame_size_ptr,
00744 AVPacket *avpkt)
00745 {
00746 int ret;
00747
00748 avctx->pkt = avpkt;
00749
00750 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
00751
00752 if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
00753 av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
00754 return -1;
00755 }
00756 if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
00757 *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){
00758 av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
00759 return -1;
00760 }
00761
00762 ret = avctx->codec->decode(avctx, samples, frame_size_ptr, avpkt);
00763 avctx->frame_number++;
00764 }else{
00765 ret= 0;
00766 *frame_size_ptr=0;
00767 }
00768 return ret;
00769 }
00770
00771 #if FF_API_SUBTITLE_OLD
00772 int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
00773 int *got_sub_ptr,
00774 const uint8_t *buf, int buf_size)
00775 {
00776 AVPacket avpkt;
00777 av_init_packet(&avpkt);
00778 avpkt.data = buf;
00779 avpkt.size = buf_size;
00780
00781 return avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, &avpkt);
00782 }
00783 #endif
00784
00785 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
00786 int *got_sub_ptr,
00787 AVPacket *avpkt)
00788 {
00789 int ret;
00790
00791 avctx->pkt = avpkt;
00792 *got_sub_ptr = 0;
00793 ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
00794 if (*got_sub_ptr)
00795 avctx->frame_number++;
00796 return ret;
00797 }
00798
00799 void avsubtitle_free(AVSubtitle *sub)
00800 {
00801 int i;
00802
00803 for (i = 0; i < sub->num_rects; i++)
00804 {
00805 av_freep(&sub->rects[i]->pict.data[0]);
00806 av_freep(&sub->rects[i]->pict.data[1]);
00807 av_freep(&sub->rects[i]->pict.data[2]);
00808 av_freep(&sub->rects[i]->pict.data[3]);
00809 av_freep(&sub->rects[i]->text);
00810 av_freep(&sub->rects[i]->ass);
00811 av_freep(&sub->rects[i]);
00812 }
00813
00814 av_freep(&sub->rects);
00815
00816 memset(sub, 0, sizeof(AVSubtitle));
00817 }
00818
00819 av_cold int avcodec_close(AVCodecContext *avctx)
00820 {
00821
00822 if (ff_lockmgr_cb) {
00823 if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
00824 return -1;
00825 }
00826
00827 entangled_thread_counter++;
00828 if(entangled_thread_counter != 1){
00829 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
00830 entangled_thread_counter--;
00831 return -1;
00832 }
00833
00834 if (HAVE_THREADS && avctx->thread_opaque)
00835 ff_thread_free(avctx);
00836 if (avctx->codec && avctx->codec->close)
00837 avctx->codec->close(avctx);
00838 avcodec_default_free_buffers(avctx);
00839 avctx->coded_frame = NULL;
00840 av_freep(&avctx->priv_data);
00841 if(avctx->codec && avctx->codec->encode)
00842 av_freep(&avctx->extradata);
00843 avctx->codec = NULL;
00844 avctx->active_thread_type = 0;
00845 entangled_thread_counter--;
00846
00847
00848 if (ff_lockmgr_cb) {
00849 (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
00850 }
00851 return 0;
00852 }
00853
00854 AVCodec *avcodec_find_encoder(enum CodecID id)
00855 {
00856 AVCodec *p, *experimental=NULL;
00857 p = first_avcodec;
00858 while (p) {
00859 if (p->encode != NULL && p->id == id) {
00860 if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) {
00861 experimental = p;
00862 } else
00863 return p;
00864 }
00865 p = p->next;
00866 }
00867 return experimental;
00868 }
00869
00870 AVCodec *avcodec_find_encoder_by_name(const char *name)
00871 {
00872 AVCodec *p;
00873 if (!name)
00874 return NULL;
00875 p = first_avcodec;
00876 while (p) {
00877 if (p->encode != NULL && strcmp(name,p->name) == 0)
00878 return p;
00879 p = p->next;
00880 }
00881 return NULL;
00882 }
00883
00884 AVCodec *avcodec_find_decoder(enum CodecID id)
00885 {
00886 AVCodec *p;
00887 p = first_avcodec;
00888 while (p) {
00889 if (p->decode != NULL && p->id == id)
00890 return p;
00891 p = p->next;
00892 }
00893 return NULL;
00894 }
00895
00896 AVCodec *avcodec_find_decoder_by_name(const char *name)
00897 {
00898 AVCodec *p;
00899 if (!name)
00900 return NULL;
00901 p = first_avcodec;
00902 while (p) {
00903 if (p->decode != NULL && strcmp(name,p->name) == 0)
00904 return p;
00905 p = p->next;
00906 }
00907 return NULL;
00908 }
00909
00910 static int get_bit_rate(AVCodecContext *ctx)
00911 {
00912 int bit_rate;
00913 int bits_per_sample;
00914
00915 switch(ctx->codec_type) {
00916 case AVMEDIA_TYPE_VIDEO:
00917 case AVMEDIA_TYPE_DATA:
00918 case AVMEDIA_TYPE_SUBTITLE:
00919 case AVMEDIA_TYPE_ATTACHMENT:
00920 bit_rate = ctx->bit_rate;
00921 break;
00922 case AVMEDIA_TYPE_AUDIO:
00923 bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
00924 bit_rate = bits_per_sample ? ctx->sample_rate * ctx->channels * bits_per_sample : ctx->bit_rate;
00925 break;
00926 default:
00927 bit_rate = 0;
00928 break;
00929 }
00930 return bit_rate;
00931 }
00932
00933 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
00934 {
00935 int i, len, ret = 0;
00936
00937 for (i = 0; i < 4; i++) {
00938 len = snprintf(buf, buf_size,
00939 isprint(codec_tag&0xFF) ? "%c" : "[%d]", codec_tag&0xFF);
00940 buf += len;
00941 buf_size = buf_size > len ? buf_size - len : 0;
00942 ret += len;
00943 codec_tag>>=8;
00944 }
00945 return ret;
00946 }
00947
00948 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
00949 {
00950 const char *codec_name;
00951 const char *profile = NULL;
00952 AVCodec *p;
00953 char buf1[32];
00954 int bitrate;
00955 AVRational display_aspect_ratio;
00956
00957 if (encode)
00958 p = avcodec_find_encoder(enc->codec_id);
00959 else
00960 p = avcodec_find_decoder(enc->codec_id);
00961
00962 if (p) {
00963 codec_name = p->name;
00964 profile = av_get_profile_name(p, enc->profile);
00965 } else if (enc->codec_id == CODEC_ID_MPEG2TS) {
00966
00967
00968 codec_name = "mpeg2ts";
00969 } else if (enc->codec_name[0] != '\0') {
00970 codec_name = enc->codec_name;
00971 } else {
00972
00973 char tag_buf[32];
00974 av_get_codec_tag_string(tag_buf, sizeof(tag_buf), enc->codec_tag);
00975 snprintf(buf1, sizeof(buf1), "%s / 0x%04X", tag_buf, enc->codec_tag);
00976 codec_name = buf1;
00977 }
00978
00979 switch(enc->codec_type) {
00980 case AVMEDIA_TYPE_VIDEO:
00981 snprintf(buf, buf_size,
00982 "Video: %s%s",
00983 codec_name, enc->mb_decision ? " (hq)" : "");
00984 if (profile)
00985 snprintf(buf + strlen(buf), buf_size - strlen(buf),
00986 " (%s)", profile);
00987 if (enc->pix_fmt != PIX_FMT_NONE) {
00988 snprintf(buf + strlen(buf), buf_size - strlen(buf),
00989 ", %s",
00990 avcodec_get_pix_fmt_name(enc->pix_fmt));
00991 }
00992 if (enc->width) {
00993 snprintf(buf + strlen(buf), buf_size - strlen(buf),
00994 ", %dx%d",
00995 enc->width, enc->height);
00996 if (enc->sample_aspect_ratio.num) {
00997 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
00998 enc->width*enc->sample_aspect_ratio.num,
00999 enc->height*enc->sample_aspect_ratio.den,
01000 1024*1024);
01001 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01002 " [PAR %d:%d DAR %d:%d]",
01003 enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den,
01004 display_aspect_ratio.num, display_aspect_ratio.den);
01005 }
01006 if(av_log_get_level() >= AV_LOG_DEBUG){
01007 int g= av_gcd(enc->time_base.num, enc->time_base.den);
01008 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01009 ", %d/%d",
01010 enc->time_base.num/g, enc->time_base.den/g);
01011 }
01012 }
01013 if (encode) {
01014 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01015 ", q=%d-%d", enc->qmin, enc->qmax);
01016 }
01017 break;
01018 case AVMEDIA_TYPE_AUDIO:
01019 snprintf(buf, buf_size,
01020 "Audio: %s",
01021 codec_name);
01022 if (profile)
01023 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01024 " (%s)", profile);
01025 if (enc->sample_rate) {
01026 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01027 ", %d Hz", enc->sample_rate);
01028 }
01029 av_strlcat(buf, ", ", buf_size);
01030 av_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
01031 if (enc->sample_fmt != AV_SAMPLE_FMT_NONE) {
01032 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01033 ", %s", av_get_sample_fmt_name(enc->sample_fmt));
01034 }
01035 break;
01036 case AVMEDIA_TYPE_DATA:
01037 snprintf(buf, buf_size, "Data: %s", codec_name);
01038 break;
01039 case AVMEDIA_TYPE_SUBTITLE:
01040 snprintf(buf, buf_size, "Subtitle: %s", codec_name);
01041 break;
01042 case AVMEDIA_TYPE_ATTACHMENT:
01043 snprintf(buf, buf_size, "Attachment: %s", codec_name);
01044 break;
01045 default:
01046 snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type);
01047 return;
01048 }
01049 if (encode) {
01050 if (enc->flags & CODEC_FLAG_PASS1)
01051 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01052 ", pass 1");
01053 if (enc->flags & CODEC_FLAG_PASS2)
01054 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01055 ", pass 2");
01056 }
01057 bitrate = get_bit_rate(enc);
01058 if (bitrate != 0) {
01059 snprintf(buf + strlen(buf), buf_size - strlen(buf),
01060 ", %d kb/s", bitrate / 1000);
01061 }
01062 }
01063
01064 const char *av_get_profile_name(const AVCodec *codec, int profile)
01065 {
01066 const AVProfile *p;
01067 if (profile == FF_PROFILE_UNKNOWN || !codec->profiles)
01068 return NULL;
01069
01070 for (p = codec->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
01071 if (p->profile == profile)
01072 return p->name;
01073
01074 return NULL;
01075 }
01076
01077 unsigned avcodec_version( void )
01078 {
01079 return LIBAVCODEC_VERSION_INT;
01080 }
01081
01082 const char *avcodec_configuration(void)
01083 {
01084 return FFMPEG_CONFIGURATION;
01085 }
01086
01087 const char *avcodec_license(void)
01088 {
01089 #define LICENSE_PREFIX "libavcodec license: "
01090 return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
01091 }
01092
01093 void avcodec_init(void)
01094 {
01095 static int initialized = 0;
01096
01097 if (initialized != 0)
01098 return;
01099 initialized = 1;
01100
01101 dsputil_static_init();
01102 }
01103
01104 void avcodec_flush_buffers(AVCodecContext *avctx)
01105 {
01106 if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
01107 ff_thread_flush(avctx);
01108 if(avctx->codec->flush)
01109 avctx->codec->flush(avctx);
01110 }
01111
01112 void avcodec_default_free_buffers(AVCodecContext *s){
01113 int i, j;
01114
01115 if(s->internal_buffer==NULL) return;
01116
01117 if (s->internal_buffer_count)
01118 av_log(s, AV_LOG_WARNING, "Found %i unreleased buffers!\n", s->internal_buffer_count);
01119 for(i=0; i<INTERNAL_BUFFER_SIZE; i++){
01120 InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i];
01121 for(j=0; j<4; j++){
01122 av_freep(&buf->base[j]);
01123 buf->data[j]= NULL;
01124 }
01125 }
01126 av_freep(&s->internal_buffer);
01127
01128 s->internal_buffer_count=0;
01129 }
01130
01131 char av_get_pict_type_char(int pict_type){
01132 switch(pict_type){
01133 case FF_I_TYPE: return 'I';
01134 case FF_P_TYPE: return 'P';
01135 case FF_B_TYPE: return 'B';
01136 case FF_S_TYPE: return 'S';
01137 case FF_SI_TYPE:return 'i';
01138 case FF_SP_TYPE:return 'p';
01139 case FF_BI_TYPE:return 'b';
01140 default: return '?';
01141 }
01142 }
01143
01144 int av_get_bits_per_sample(enum CodecID codec_id){
01145 switch(codec_id){
01146 case CODEC_ID_ADPCM_SBPRO_2:
01147 return 2;
01148 case CODEC_ID_ADPCM_SBPRO_3:
01149 return 3;
01150 case CODEC_ID_ADPCM_SBPRO_4:
01151 case CODEC_ID_ADPCM_CT:
01152 case CODEC_ID_ADPCM_IMA_WAV:
01153 case CODEC_ID_ADPCM_MS:
01154 case CODEC_ID_ADPCM_YAMAHA:
01155 return 4;
01156 case CODEC_ID_PCM_ALAW:
01157 case CODEC_ID_PCM_MULAW:
01158 case CODEC_ID_PCM_S8:
01159 case CODEC_ID_PCM_U8:
01160 case CODEC_ID_PCM_ZORK:
01161 return 8;
01162 case CODEC_ID_PCM_S16BE:
01163 case CODEC_ID_PCM_S16LE:
01164 case CODEC_ID_PCM_S16LE_PLANAR:
01165 case CODEC_ID_PCM_U16BE:
01166 case CODEC_ID_PCM_U16LE:
01167 return 16;
01168 case CODEC_ID_PCM_S24DAUD:
01169 case CODEC_ID_PCM_S24BE:
01170 case CODEC_ID_PCM_S24LE:
01171 case CODEC_ID_PCM_U24BE:
01172 case CODEC_ID_PCM_U24LE:
01173 return 24;
01174 case CODEC_ID_PCM_S32BE:
01175 case CODEC_ID_PCM_S32LE:
01176 case CODEC_ID_PCM_U32BE:
01177 case CODEC_ID_PCM_U32LE:
01178 case CODEC_ID_PCM_F32BE:
01179 case CODEC_ID_PCM_F32LE:
01180 return 32;
01181 case CODEC_ID_PCM_F64BE:
01182 case CODEC_ID_PCM_F64LE:
01183 return 64;
01184 default:
01185 return 0;
01186 }
01187 }
01188
01189 #if FF_API_OLD_SAMPLE_FMT
01190 int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt) {
01191 return av_get_bits_per_sample_fmt(sample_fmt);
01192 }
01193 #endif
01194
01195 #if !HAVE_THREADS
01196 int ff_thread_init(AVCodecContext *s, int thread_count){
01197 s->thread_count = thread_count;
01198 return -1;
01199 }
01200 #endif
01201
01202 unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
01203 {
01204 unsigned int n = 0;
01205
01206 while(v >= 0xff) {
01207 *s++ = 0xff;
01208 v -= 0xff;
01209 n++;
01210 }
01211 *s = v;
01212 n++;
01213 return n;
01214 }
01215
01216 #if LIBAVCODEC_VERSION_MAJOR < 53
01217 #include "libavutil/parseutils.h"
01218
01219 int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str)
01220 {
01221 return av_parse_video_size(width_ptr, height_ptr, str);
01222 }
01223
01224 int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg)
01225 {
01226 return av_parse_video_rate(frame_rate, arg);
01227 }
01228 #endif
01229
01230 int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){
01231 int i;
01232 for(i=0; i<size && !(tab[i][0]==a && tab[i][1]==b); i++);
01233 return i;
01234 }
01235
01236 void av_log_missing_feature(void *avc, const char *feature, int want_sample)
01237 {
01238 av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg "
01239 "version to the newest one from Git. If the problem still "
01240 "occurs, it means that your file has a feature which has not "
01241 "been implemented.", feature);
01242 if(want_sample)
01243 av_log_ask_for_sample(avc, NULL);
01244 else
01245 av_log(avc, AV_LOG_WARNING, "\n");
01246 }
01247
01248 void av_log_ask_for_sample(void *avc, const char *msg)
01249 {
01250 if (msg)
01251 av_log(avc, AV_LOG_WARNING, "%s ", msg);
01252 av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
01253 "of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ "
01254 "and contact the ffmpeg-devel mailing list.\n");
01255 }
01256
01257 static AVHWAccel *first_hwaccel = NULL;
01258
01259 void av_register_hwaccel(AVHWAccel *hwaccel)
01260 {
01261 AVHWAccel **p = &first_hwaccel;
01262 while (*p)
01263 p = &(*p)->next;
01264 *p = hwaccel;
01265 hwaccel->next = NULL;
01266 }
01267
01268 AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
01269 {
01270 return hwaccel ? hwaccel->next : first_hwaccel;
01271 }
01272
01273 AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt)
01274 {
01275 AVHWAccel *hwaccel=NULL;
01276
01277 while((hwaccel= av_hwaccel_next(hwaccel))){
01278 if ( hwaccel->id == codec_id
01279 && hwaccel->pix_fmt == pix_fmt)
01280 return hwaccel;
01281 }
01282 return NULL;
01283 }
01284
01285 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
01286 {
01287 if (ff_lockmgr_cb) {
01288 if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY))
01289 return -1;
01290 }
01291
01292 ff_lockmgr_cb = cb;
01293
01294 if (ff_lockmgr_cb) {
01295 if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE))
01296 return -1;
01297 }
01298 return 0;
01299 }
01300
01301 unsigned int ff_toupper4(unsigned int x)
01302 {
01303 return toupper( x &0xFF)
01304 + (toupper((x>>8 )&0xFF)<<8 )
01305 + (toupper((x>>16)&0xFF)<<16)
01306 + (toupper((x>>24)&0xFF)<<24);
01307 }
01308
01309 #if !HAVE_PTHREADS
01310
01311 int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
01312 {
01313 f->owner = avctx;
01314 return avctx->get_buffer(avctx, f);
01315 }
01316
01317 void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
01318 {
01319 f->owner->release_buffer(f->owner, f);
01320 }
01321
01322 void ff_thread_finish_setup(AVCodecContext *avctx)
01323 {
01324 }
01325
01326 void ff_thread_report_progress(AVFrame *f, int progress, int field)
01327 {
01328 }
01329
01330 void ff_thread_await_progress(AVFrame *f, int progress, int field)
01331 {
01332 }
01333
01334 #endif
01335
01336 #if LIBAVCODEC_VERSION_MAJOR < 53
01337
01338 int avcodec_thread_init(AVCodecContext *s, int thread_count)
01339 {
01340 return ff_thread_init(s, thread_count);
01341 }
01342
01343 void avcodec_thread_free(AVCodecContext *s)
01344 {
01345 #if HAVE_THREADS
01346 ff_thread_free(s);
01347 #endif
01348 }
01349
01350 #endif