Revision b38f008e libavcodec/utils.c

View differences:

libavcodec/utils.c
37 37
#include "dsputil.h"
38 38
#include "libavutil/opt.h"
39 39
#include "imgconvert.h"
40
#include "thread.h"
40 41
#include "audioconvert.h"
41 42
#include "internal.h"
42 43
#include <stdlib.h>
......
261 262
    (*picture_number)++;
262 263

  
263 264
    if(buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)){
265
        if(s->active_thread_type&FF_THREAD_FRAME) {
266
            av_log_missing_feature(s, "Width/height changing with frame threads is", 0);
267
            return -1;
268
        }
269

  
264 270
        for(i=0; i<4; i++){
265 271
            av_freep(&buf->base[i]);
266 272
            buf->data[i]= NULL;
......
532 538
        goto free_and_end;
533 539
    }
534 540
    avctx->frame_number = 0;
541

  
542
    if (HAVE_THREADS && !avctx->thread_opaque) {
543
        ret = avcodec_thread_init(avctx, avctx->thread_count);
544
        if (ret < 0) {
545
            goto free_and_end;
546
        }
547
    }
548

  
535 549
    if (avctx->codec->max_lowres < avctx->lowres) {
536 550
        av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
537 551
               avctx->codec->max_lowres);
......
543 557
    avctx->pts_correction_last_pts =
544 558
    avctx->pts_correction_last_dts = INT64_MIN;
545 559

  
546
    if(avctx->codec->init){
560
    if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
547 561
        ret = avctx->codec->init(avctx);
548 562
        if (ret < 0) {
549 563
            goto free_and_end;
......
674 688

  
675 689
    avctx->pkt = avpkt;
676 690

  
677
    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
678
        ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
679
                                avpkt);
691
    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
692
        if (HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
693
             ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
694
                                          avpkt);
695
        else {
696
            ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
697
                              avpkt);
698
            picture->pkt_dts= avpkt->dts;
699
        }
680 700

  
681 701
        emms_c(); //needed to avoid an emms_c() call before every return;
682 702

  
683
        picture->pkt_dts= avpkt->dts;
684 703
        picture->best_effort_timestamp = guess_correct_pts(avctx,
685 704
                                                           picture->pkt_pts,
686 705
                                                           picture->pkt_dts);
......
809 828
    if(avctx->codec && avctx->codec->encode)
810 829
        av_freep(&avctx->extradata);
811 830
    avctx->codec = NULL;
831
    avctx->active_thread_type = 0;
812 832
    entangled_thread_counter--;
813 833

  
814 834
    /* Release any user-supplied mutex. */
......
1070 1090

  
1071 1091
void avcodec_flush_buffers(AVCodecContext *avctx)
1072 1092
{
1093
    if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
1094
        ff_thread_flush(avctx);
1073 1095
    if(avctx->codec->flush)
1074 1096
        avctx->codec->flush(avctx);
1075 1097
}
......
1270 1292
            + (toupper((x>>16)&0xFF)<<16)
1271 1293
            + (toupper((x>>24)&0xFF)<<24);
1272 1294
}
1295

  
1296
#if !HAVE_PTHREADS
1297

  
1298
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
1299
{
1300
    f->owner = avctx;
1301
    return avctx->get_buffer(avctx, f);
1302
}
1303

  
1304
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
1305
{
1306
    f->owner->release_buffer(f->owner, f);
1307
}
1308

  
1309
void ff_thread_finish_setup(AVCodecContext *avctx)
1310
{
1311
}
1312

  
1313
void ff_thread_report_progress(AVFrame *f, int progress, int field)
1314
{
1315
}
1316

  
1317
void ff_thread_await_progress(AVFrame *f, int progress, int field)
1318
{
1319
}
1320

  
1321
#endif

Also available in: Unified diff