Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 526434
Collapse All | Expand All

(-)src/ffDiaporama/engine/cBaseMediaFile.cpp (-40 / +50 lines)
Lines 1861-1872 Link Here
1861
}
1861
}
1862
1862
1863
cImageInCache::~cImageInCache() {
1863
cImageInCache::~cImageInCache() {
1864
    #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
1864
    #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
1865
    if (FrameBufferYUV->opaque) {
1865
    if (FrameBufferYUV->opaque) {
1866
        avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
1866
        avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
1867
        FrameBufferYUV->opaque=NULL;
1867
        FrameBufferYUV->opaque=NULL;
1868
    }
1868
    }
1869
    #elif defined(FFMPEG) && (FFMPEGVERSIONINT>=201)
1869
    #else
1870
    if (FiltFrame) {
1870
    if (FiltFrame) {
1871
        av_frame_unref(FiltFrame);
1871
        av_frame_unref(FiltFrame);
1872
        av_frame_free(&FiltFrame);
1872
        av_frame_free(&FiltFrame);
Lines 2239-2245 Link Here
2239
                    LibavFile->streams[VideoStreamNumber]->discard=AVDISCARD_DEFAULT;  // Setup STREAM options
2239
                    LibavFile->streams[VideoStreamNumber]->discard=AVDISCARD_DEFAULT;  // Setup STREAM options
2240
2240
2241
                    // Setup decoder options
2241
                    // Setup decoder options
2242
                    LibavFile->streams[VideoStreamNumber]->codec->debug_mv         =0;                    // Debug level (0=nothing)
2242
                    //LibavFile->streams[VideoStreamNumber]->codec->debug_mv         =0;                    // Debug level (0=nothing)
2243
                    LibavFile->streams[VideoStreamNumber]->codec->debug            =0;                    // Debug level (0=nothing)
2243
                    LibavFile->streams[VideoStreamNumber]->codec->debug            =0;                    // Debug level (0=nothing)
2244
                    LibavFile->streams[VideoStreamNumber]->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
2244
                    LibavFile->streams[VideoStreamNumber]->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
2245
                    LibavFile->streams[VideoStreamNumber]->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
2245
                    LibavFile->streams[VideoStreamNumber]->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
Lines 2256-2267 Link Here
2256
                    if (avcodec_open2(LibavFile->streams[VideoStreamNumber]->codec,Codec,NULL)>=0) {
2256
                    if (avcodec_open2(LibavFile->streams[VideoStreamNumber]->codec,Codec,NULL)>=0) {
2257
                        // Get Aspect Ratio
2257
                        // Get Aspect Ratio
2258
2258
2259
                        AspectRatio=double(LibavFile->streams[VideoStreamNumber]->codec->sample_aspect_ratio.num)/double(LibavFile->streams[VideoStreamNumber]->codec->sample_aspect_ratio.den);
2259
                        if (LibavFile->streams[VideoStreamNumber]->codec->sample_aspect_ratio.num!=0)
2260
2260
                            AspectRatio=double(LibavFile->streams[VideoStreamNumber]->codec->sample_aspect_ratio.num)/double(LibavFile->streams[VideoStreamNumber]->codec->sample_aspect_ratio.den);
2261
                        if (LibavFile->streams[VideoStreamNumber]->sample_aspect_ratio.num!=0)
2261
                        else if (LibavFile->streams[VideoStreamNumber]->sample_aspect_ratio.num!=0)
2262
                            AspectRatio=double(LibavFile->streams[VideoStreamNumber]->sample_aspect_ratio.num)/double(LibavFile->streams[VideoStreamNumber]->sample_aspect_ratio.den);
2262
                            AspectRatio=double(LibavFile->streams[VideoStreamNumber]->sample_aspect_ratio.num)/double(LibavFile->streams[VideoStreamNumber]->sample_aspect_ratio.den);
2263
2263
                        else
2264
                        if (AspectRatio==0) AspectRatio=1;
2264
                            AspectRatio=1;
2265
2265
2266
                        // Special case for DVD mode video without PAR
2266
                        // Special case for DVD mode video without PAR
2267
                        if ((AspectRatio==1)&&(LibavFile->streams[VideoStreamNumber]->codec->coded_width==720)&&((LibavFile->streams[VideoStreamNumber]->codec->coded_height==576)||(LibavFile->streams[VideoStreamNumber]->codec->coded_height==480)))
2267
                        if ((AspectRatio==1)&&(LibavFile->streams[VideoStreamNumber]->codec->coded_width==720)&&((LibavFile->streams[VideoStreamNumber]->codec->coded_height==576)||(LibavFile->streams[VideoStreamNumber]->codec->coded_height==480)))
Lines 2384-2390 Link Here
2384
                    AVCodec *ThumbDecoderCodec=avcodec_find_decoder(ThumbStream->codec->codec_id);
2384
                    AVCodec *ThumbDecoderCodec=avcodec_find_decoder(ThumbStream->codec->codec_id);
2385
2385
2386
                    // Setup decoder options
2386
                    // Setup decoder options
2387
                    ThumbStream->codec->debug_mv         =0;                    // Debug level (0=nothing)
2387
                    //ThumbStream->codec->debug_mv         =0;                    // Debug level (0=nothing)
2388
                    ThumbStream->codec->debug            =0;                    // Debug level (0=nothing)
2388
                    ThumbStream->codec->debug            =0;                    // Debug level (0=nothing)
2389
                    ThumbStream->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
2389
                    ThumbStream->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
2390
                    ThumbStream->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
2390
                    ThumbStream->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
Lines 2552-2558 Link Here
2552
    }
2552
    }
2553
2553
2554
    if (FrameBufferYUV!=NULL) {
2554
    if (FrameBufferYUV!=NULL) {
2555
        #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
2555
        #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
2556
        if (FrameBufferYUV->opaque) {
2556
        if (FrameBufferYUV->opaque) {
2557
            avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
2557
            avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
2558
            FrameBufferYUV->opaque=NULL;
2558
            FrameBufferYUV->opaque=NULL;
Lines 2572-2578 Link Here
2572
    if (RSC) {
2572
    if (RSC) {
2573
        #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
2573
        #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
2574
            audio_resample_close(RSC);
2574
            audio_resample_close(RSC);
2575
        #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
2575
        #elif defined(LIBAV)
2576
            avresample_close(RSC);
2576
            avresample_close(RSC);
2577
            avresample_free(&RSC);
2577
            avresample_free(&RSC);
2578
        #elif defined(FFMPEG)
2578
        #elif defined(FFMPEG)
Lines 2619-2625 Link Here
2619
                1,                                          // linear
2619
                1,                                          // linear
2620
                0);                                         // cutoff
2620
                0);                                         // cutoff
2621
            if (!RSC) ToLog(LOGMSG_CRITICAL,QString("CheckResampler: av_audio_resample_init failed"));
2621
            if (!RSC) ToLog(LOGMSG_CRITICAL,QString("CheckResampler: av_audio_resample_init failed"));
2622
        #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
2622
        #elif defined(LIBAV)
2623
            this->RSC_InChannelLayout =RSC_InChannelLayout;
2623
            this->RSC_InChannelLayout =RSC_InChannelLayout;
2624
            this->RSC_OutChannelLayout=RSC_OutChannelLayout;
2624
            this->RSC_OutChannelLayout=RSC_OutChannelLayout;
2625
            RSC=avresample_alloc_context();
2625
            RSC=avresample_alloc_context();
Lines 2704-2710 Link Here
2704
        AVFilterInOut *outputs = (AVFilterInOut *)av_malloc(sizeof(AVFilterInOut));
2704
        AVFilterInOut *outputs = (AVFilterInOut *)av_malloc(sizeof(AVFilterInOut));
2705
        AVFilterInOut *inputs  = (AVFilterInOut *)av_malloc(sizeof(AVFilterInOut));
2705
        AVFilterInOut *inputs  = (AVFilterInOut *)av_malloc(sizeof(AVFilterInOut));
2706
2706
2707
    #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
2707
    #elif defined(LIBAV)
2708
2708
2709
        QString args=QString("%1:%2:%3:%4:%5:%6:%7")
2709
        QString args=QString("%1:%2:%3:%4:%5:%6:%7")
2710
            .arg(LibavVideoFile->streams[VideoStreamNumber]->codec->width)
2710
            .arg(LibavVideoFile->streams[VideoStreamNumber]->codec->width)
Lines 2768-2777 Link Here
2768
    inputs->pad_idx = 0;
2768
    inputs->pad_idx = 0;
2769
    inputs->next = NULL;
2769
    inputs->next = NULL;
2770
2770
2771
    #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
2771
    #if defined(LIBAV)
2772
    if ((result=avfilter_graph_parse(VideoFilterGraph,QString("yadif=1:-1").toLocal8Bit().constData(),inputs,outputs,NULL))<0) {
2772
    if ((result=avfilter_graph_parse(VideoFilterGraph,QString("yadif=1:-1").toLocal8Bit().constData(),inputs,outputs,NULL))<0) {
2773
    #elif (defined(LIBAV) && (LIBAVVERSIONINT<=9))
2774
    if ((result=avfilter_graph_parse(VideoFilterGraph,QString("yadif=deint=interlaced:mode=send_frame:parity=auto").toLocal8Bit().constData(),inputs,outputs,NULL))<0) {
2775
    #elif (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
2773
    #elif (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
2776
    if ((result=avfilter_graph_parse(VideoFilterGraph,QString("yadif=deint=interlaced:mode=send_frame:parity=auto").toLocal8Bit().constData(),&inputs,&outputs,NULL))<0) {
2774
    if ((result=avfilter_graph_parse(VideoFilterGraph,QString("yadif=deint=interlaced:mode=send_frame:parity=auto").toLocal8Bit().constData(),&inputs,&outputs,NULL))<0) {
2777
    #elif defined(FFMPEG)&&(FFMPEGVERSIONINT>=201)
2775
    #elif defined(FFMPEG)&&(FFMPEGVERSIONINT>=201)
Lines 2799-2805 Link Here
2799
2797
2800
//====================================================================================================================
2798
//====================================================================================================================
2801
2799
2802
#if defined(LIBAV) || (FFMPEGVERSIONINT<201)
2800
#if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
2803
    int cVideoFile::VideoFilter_Process() {
2801
    int cVideoFile::VideoFilter_Process() {
2804
        #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
2802
        #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
2805
            // LIBAV 8
2803
            // LIBAV 8
Lines 2831-2837 Link Here
2831
                FrameBufferYUV->opaque=(void *)avfilter_ref_buffer(VideoFilterOut->inputs[0]->cur_buf,AV_PERM_READ);
2829
                FrameBufferYUV->opaque=(void *)avfilter_ref_buffer(VideoFilterOut->inputs[0]->cur_buf,AV_PERM_READ);
2832
            }
2830
            }
2833
2831
2834
        #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
2832
        #elif defined(LIBAV)
2835
            // LIBAV9
2833
            // LIBAV9
2836
            AVFilterBufferRef *m_pBufferRef=NULL;
2834
            AVFilterBufferRef *m_pBufferRef=NULL;
2837
            int Ret=av_buffersrc_write_frame(VideoFilterIn,FrameBufferYUV);
2835
            int Ret=av_buffersrc_write_frame(VideoFilterIn,FrameBufferYUV);
Lines 2964-2970 Link Here
2964
    #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
2962
    #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
2965
        Data=(u_int8_t *)av_malloc(MaxAudioLenDecoded);
2963
        Data=(u_int8_t *)av_malloc(MaxAudioLenDecoded);
2966
        if (Data) *SizeDecoded=audio_resample(RSC,(short int*)Data,(short int*)Frame->data[0],Frame->nb_samples)*DstSampleSize;
2964
        if (Data) *SizeDecoded=audio_resample(RSC,(short int*)Data,(short int*)Frame->data[0],Frame->nb_samples)*DstSampleSize;
2967
    #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
2965
    #elif defined(LIBAV)
2968
        u_int8_t *in_data[RESAMPLE_MAX_CHANNELS]={0};
2966
        u_int8_t *in_data[RESAMPLE_MAX_CHANNELS]={0};
2969
        int     in_linesize=0;
2967
        int     in_linesize=0;
2970
        Data=Frame->data[0];
2968
        Data=Frame->data[0];
Lines 2979-2985 Link Here
2979
            } else if (av_samples_fill_arrays(out_data,&out_linesize,Data,RSC_OutChannels,out_samples,RSC_OutSampleFmt,1)<0) {
2977
            } else if (av_samples_fill_arrays(out_data,&out_linesize,Data,RSC_OutChannels,out_samples,RSC_OutSampleFmt,1)<0) {
2980
                ToLog(LOGMSG_CRITICAL,QString("failed out_data fill arrays"));
2978
                ToLog(LOGMSG_CRITICAL,QString("failed out_data fill arrays"));
2981
            } else {
2979
            } else {
2982
                *SizeDecoded=avresample_convert(RSC,out_data,out_linesize,out_samples,in_data,in_linesize,Frame->nb_samples)*DstSampleSize;
2980
                *SizeDecoded=avresample_convert(RSC,out_data,out_linesize,out_samples,Frame->data,in_linesize,Frame->nb_samples)*DstSampleSize;
2983
            }
2981
            }
2984
        }
2982
        }
2985
    #elif defined(FFMPEG)
2983
    #elif defined(FFMPEG)
Lines 3024-3030 Link Here
3024
3022
3025
    if (!FPSDuration) {
3023
    if (!FPSDuration) {
3026
        if (PreviewMode) FPSDuration=double(AV_TIME_BASE)/((cApplicationConfig *)ApplicationConfig)->PreviewFPS;
3024
        if (PreviewMode) FPSDuration=double(AV_TIME_BASE)/((cApplicationConfig *)ApplicationConfig)->PreviewFPS;
3027
            else if (VideoStream) FPSDuration=double(VideoStream->r_frame_rate.den*AV_TIME_BASE)/double(VideoStream->r_frame_rate.num);
3025
            else if (VideoStream) FPSDuration=double(VideoStream->avg_frame_rate.den*AV_TIME_BASE)/double(VideoStream->avg_frame_rate.num);
3028
            else FPSDuration=double(AV_TIME_BASE)/double(SoundTrackBloc->SamplingRate);
3026
            else FPSDuration=double(AV_TIME_BASE)/double(SoundTrackBloc->SamplingRate);
3029
    }
3027
    }
3030
    // If position >= end of file : disable audio
3028
    // If position >= end of file : disable audio
Lines 3164-3170 Link Here
3164
                                Data=Frame->data[0];
3162
                                Data=Frame->data[0];
3165
                                #if (defined(LIBAV)&&(LIBAVVERSIONINT<=8))
3163
                                #if (defined(LIBAV)&&(LIBAVVERSIONINT<=8))
3166
                                SizeDecoded=Frame->nb_samples*av_get_bytes_per_sample(AudioStream->codec->sample_fmt)*AudioStream->codec->channels;
3164
                                SizeDecoded=Frame->nb_samples*av_get_bytes_per_sample(AudioStream->codec->sample_fmt)*AudioStream->codec->channels;
3167
                                #elif (defined(LIBAV)&&(LIBAVVERSIONINT<=9))
3165
                                #elif defined(LIBAV)
3168
                                SizeDecoded=av_samples_get_buffer_size(NULL,AudioStream->codec->channels,Frame->nb_samples,AudioStream->codec->sample_fmt,0);
3166
                                SizeDecoded=av_samples_get_buffer_size(NULL,AudioStream->codec->channels,Frame->nb_samples,AudioStream->codec->sample_fmt,0);
3169
                                #elif defined(FFMPEG)
3167
                                #elif defined(FFMPEG)
3170
                                SizeDecoded=Frame->nb_samples*av_get_bytes_per_sample(AudioStream->codec->sample_fmt)*AudioStream->codec->channels;
3168
                                SizeDecoded=Frame->nb_samples*av_get_bytes_per_sample(AudioStream->codec->sample_fmt)*AudioStream->codec->channels;
Lines 3290-3296 Link Here
3290
                            if (FrameBufferYUV==NULL) FrameBufferYUV=ALLOCFRAME();
3288
                            if (FrameBufferYUV==NULL) FrameBufferYUV=ALLOCFRAME();
3291
                            if (FrameBufferYUV) {
3289
                            if (FrameBufferYUV) {
3292
3290
3293
                                #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3291
                                #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3294
                                if (FrameBufferYUV->opaque) {
3292
                                if (FrameBufferYUV->opaque) {
3295
                                    avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
3293
                                    avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
3296
                                    FrameBufferYUV->opaque=NULL;
3294
                                    FrameBufferYUV->opaque=NULL;
Lines 3324-3337 Link Here
3324
                                    if ((Deinterlace)&&(!VideoFilterGraph))           VideoFilter_Open();
3322
                                    if ((Deinterlace)&&(!VideoFilterGraph))           VideoFilter_Open();
3325
                                        else if ((!Deinterlace)&&(VideoFilterGraph))  VideoFilter_Close();
3323
                                        else if ((!Deinterlace)&&(VideoFilterGraph))  VideoFilter_Close();
3326
3324
3327
                                    #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3325
                                    #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3328
                                    if (VideoFilterGraph) VideoFilter_Process();
3326
                                    if (VideoFilterGraph) VideoFilter_Process();
3329
                                    #elif defined(FFMPEG)&&(FFMPEGVERSIONINT>=201)
3327
                                    #elif (defined(LIBAV)&&(LIBAVVERSIONINT>=10) || defined(FFMPEG)&&(FFMPEGVERSIONINT>=201))
3330
                                    AVFrame *FiltFrame=NULL;
3328
                                    AVFrame *FiltFrame=NULL;
3331
                                    if (VideoFilterGraph) {
3329
                                    if (VideoFilterGraph) {
3332
                                        // FFMPEG 2.0
3330
                                        // FFMPEG 2.0 / LIBAV 10
3333
                                        // push the decoded frame into the filtergraph
3331
                                        // push the decoded frame into the filtergraph
3334
                                        if (av_buffersrc_add_frame_flags(VideoFilterIn,FrameBufferYUV,AV_BUFFERSRC_FLAG_KEEP_REF)<0) {
3332
                                        if (av_buffersrc_write_frame(VideoFilterIn,FrameBufferYUV)<0) {
3335
                                            ToLog(LOGMSG_INFORMATION,"IN:cVideoFile::ReadFrame : Error while feeding the filtergraph");
3333
                                            ToLog(LOGMSG_INFORMATION,"IN:cVideoFile::ReadFrame : Error while feeding the filtergraph");
3336
                                        } else {
3334
                                        } else {
3337
                                            FiltFrame=av_frame_alloc();
3335
                                            FiltFrame=av_frame_alloc();
Lines 3364-3370 Link Here
3364
3362
3365
                                        // Append this frame
3363
                                        // Append this frame
3366
                                        cImageInCache *ObjImage=
3364
                                        cImageInCache *ObjImage=
3367
                                            #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3365
                                            #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3368
                                                new cImageInCache(FrameBufferYUVPosition,NULL,FrameBufferYUV);
3366
                                                new cImageInCache(FrameBufferYUVPosition,NULL,FrameBufferYUV);
3369
                                            #else
3367
                                            #else
3370
                                                new cImageInCache(FrameBufferYUVPosition,FiltFrame,FrameBufferYUV);
3368
                                                new cImageInCache(FrameBufferYUVPosition,FiltFrame,FrameBufferYUV);
Lines 3386-3392 Link Here
3386
                                        IsVideoFind=Nbr>0;
3384
                                        IsVideoFind=Nbr>0;
3387
                                    }
3385
                                    }
3388
                                    if (FreeFrames) {
3386
                                    if (FreeFrames) {
3389
                                        #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3387
                                        #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3390
                                        if (FrameBufferYUV->opaque) {
3388
                                        if (FrameBufferYUV->opaque) {
3391
                                            avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
3389
                                            avfilter_unref_buffer((AVFilterBufferRef *)FrameBufferYUV->opaque);
3392
                                            FrameBufferYUV->opaque=NULL;
3390
                                            FrameBufferYUV->opaque=NULL;
Lines 3401-3407 Link Here
3401
                                        FREEFRAME(&FrameBufferYUV);
3399
                                        FREEFRAME(&FrameBufferYUV);
3402
                                    } else {
3400
                                    } else {
3403
                                        FrameBufferYUV=NULL;
3401
                                        FrameBufferYUV=NULL;
3404
                                        #if defined(FFMPEG)&&(FFMPEGVERSIONINT>=201)
3402
                                        #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=201) || defined(LIBAV)&&(LIBAVVERSIONINT>=10))
3405
                                        FiltFrame     =NULL;
3403
                                        FiltFrame     =NULL;
3406
                                        #endif
3404
                                        #endif
3407
                                    }
3405
                                    }
Lines 3490-3496 Link Here
3490
3488
3491
        if (img_convert_ctx!=NULL) {
3489
        if (img_convert_ctx!=NULL) {
3492
            int ret;
3490
            int ret;
3493
            #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3491
            #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
3494
            if (Frame->opaque) {
3492
            if (Frame->opaque) {
3495
                AVFilterBufferRef *Buf=(AVFilterBufferRef *)Frame->opaque;
3493
                AVFilterBufferRef *Buf=(AVFilterBufferRef *)Frame->opaque;
3496
                ret = sws_scale(
3494
                ret = sws_scale(
Lines 3565-3576 Link Here
3565
int cVideoFile::getThreadFlags(AVCodecID ID) {
3563
int cVideoFile::getThreadFlags(AVCodecID ID) {
3566
    int Ret=0;
3564
    int Ret=0;
3567
    switch (ID) {
3565
    switch (ID) {
3568
        case CODEC_ID_PRORES:
3566
        case AV_CODEC_ID_PRORES:
3569
        case CODEC_ID_MPEG1VIDEO:
3567
        case AV_CODEC_ID_MPEG1VIDEO:
3570
        case CODEC_ID_DVVIDEO:
3568
        case AV_CODEC_ID_DVVIDEO:
3571
        case CODEC_ID_MPEG2VIDEO:   Ret=FF_THREAD_SLICE;                    break;
3569
        case AV_CODEC_ID_MPEG2VIDEO:   Ret=FF_THREAD_SLICE;                    break;
3572
        case CODEC_ID_H264 :        Ret=FF_THREAD_FRAME|FF_THREAD_SLICE;    break;
3570
        case AV_CODEC_ID_H264 :        Ret=FF_THREAD_FRAME|FF_THREAD_SLICE;    break;
3573
        default:                    Ret=FF_THREAD_FRAME;                    break;
3571
        default:                       Ret=FF_THREAD_FRAME;                    break;
3574
    }
3572
    }
3575
    return Ret;
3573
    return Ret;
3576
}
3574
}
Lines 3607-3613 Link Here
3607
        AudioDecoderCodec=avcodec_find_decoder(AudioStream->codec->codec_id);
3605
        AudioDecoderCodec=avcodec_find_decoder(AudioStream->codec->codec_id);
3608
3606
3609
        // Setup decoder options
3607
        // Setup decoder options
3610
        AudioStream->codec->debug_mv         =0;                    // Debug level (0=nothing)
3608
        //AudioStream->codec->debug_mv         =0;                    // Debug level (0=nothing)
3611
        AudioStream->codec->debug            =0;                    // Debug level (0=nothing)
3609
        AudioStream->codec->debug            =0;                    // Debug level (0=nothing)
3612
        AudioStream->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
3610
        AudioStream->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
3613
        AudioStream->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
3611
        AudioStream->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
Lines 3648-3654 Link Here
3648
        VideoDecoderCodec=avcodec_find_decoder(VideoStream->codec->codec_id);
3646
        VideoDecoderCodec=avcodec_find_decoder(VideoStream->codec->codec_id);
3649
3647
3650
        // Setup decoder options
3648
        // Setup decoder options
3651
        VideoStream->codec->debug_mv         =0;                    // Debug level (0=nothing)
3649
        //VideoStream->codec->debug_mv         =0;                    // Debug level (0=nothing)
3652
        VideoStream->codec->debug            =0;                    // Debug level (0=nothing)
3650
        VideoStream->codec->debug            =0;                    // Debug level (0=nothing)
3653
        VideoStream->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
3651
        VideoStream->codec->workaround_bugs  =1;                    // Work around bugs in encoders which sometimes cannot be detected automatically : 1=autodetection
3654
        VideoStream->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
3652
        VideoStream->codec->idct_algo        =FF_IDCT_AUTO;         // IDCT algorithm, 0=auto
Lines 3662-3668 Link Here
3662
        // Hack to correct wrong frame rates that seem to be generated by some codecs
3660
        // Hack to correct wrong frame rates that seem to be generated by some codecs
3663
        if (VideoStream->codec->time_base.num>1000 && VideoStream->codec->time_base.den==1)
3661
        if (VideoStream->codec->time_base.num>1000 && VideoStream->codec->time_base.den==1)
3664
            VideoStream->codec->time_base.den=1000;
3662
            VideoStream->codec->time_base.den=1000;
3665
3663
            
3664
        if (VideoStream->codec->time_base.num == 0) {
3665
          VideoStream->codec->time_base.num = VideoStream->avg_frame_rate.den;
3666
          VideoStream->codec->time_base.den = VideoStream->avg_frame_rate.num;
3667
        }          
3668
        
3669
        if (VideoStream->codec->sample_aspect_ratio.num == 0) {
3670
          if (VideoStream->sample_aspect_ratio.num == 0)
3671
            VideoStream->codec->sample_aspect_ratio.num = VideoStream->codec->sample_aspect_ratio.den = 1;
3672
          else
3673
            VideoStream->codec->sample_aspect_ratio = VideoStream->sample_aspect_ratio;
3674
        }
3675
        
3666
        if ((VideoDecoderCodec==NULL)||(avcodec_open2(VideoStream->codec,VideoDecoderCodec,NULL)<0)) return false;
3676
        if ((VideoDecoderCodec==NULL)||(avcodec_open2(VideoStream->codec,VideoDecoderCodec,NULL)<0)) return false;
3667
        LibavStartTime=LibavVideoFile->start_time;
3677
        LibavStartTime=LibavVideoFile->start_time;
3668
    }
3678
    }
(-)src/ffDiaporama/engine/cBaseMediaFile.h (-2 / +2 lines)
Lines 429-435 Link Here
429
429
430
    virtual int             VideoFilter_Open();
430
    virtual int             VideoFilter_Open();
431
    virtual void            VideoFilter_Close();
431
    virtual void            VideoFilter_Close();
432
    #if defined(LIBAV) || (FFMPEGVERSIONINT<201)
432
    #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
433
        virtual int         VideoFilter_Process();
433
        virtual int         VideoFilter_Process();
434
    #endif
434
    #endif
435
435
Lines 444-450 Link Here
444
    // Audio resampling
444
    // Audio resampling
445
    #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
445
    #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
446
    ReSampleContext         *RSC;
446
    ReSampleContext         *RSC;
447
    #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
447
    #elif defined(LIBAV)
448
    AVAudioResampleContext  *RSC;
448
    AVAudioResampleContext  *RSC;
449
    uint64_t                RSC_InChannelLayout,RSC_OutChannelLayout;
449
    uint64_t                RSC_InChannelLayout,RSC_OutChannelLayout;
450
    #elif defined(FFMPEG)
450
    #elif defined(FFMPEG)
(-)src/ffDiaporama/engine/cDeviceModelDef.h (-2 / +12 lines)
Lines 65-71 Link Here
65
65
66
#if (LIBAVUTIL_VERSION_MICRO<100)&&(LIBAVCODEC_VERSION_MICRO<100)&&(LIBAVFORMAT_VERSION_MICRO<100)&&(LIBAVDEVICE_VERSION_MICRO<100)&&(LIBAVFILTER_VERSION_MICRO<100)&&(LIBSWSCALE_VERSION_MICRO<100)
66
#if (LIBAVUTIL_VERSION_MICRO<100)&&(LIBAVCODEC_VERSION_MICRO<100)&&(LIBAVFORMAT_VERSION_MICRO<100)&&(LIBAVDEVICE_VERSION_MICRO<100)&&(LIBAVFILTER_VERSION_MICRO<100)&&(LIBSWSCALE_VERSION_MICRO<100)
67
    #define LIBAV
67
    #define LIBAV
68
    #if ((LIBAVUTIL_VERSION_INT>=AV_VERSION_INT(52,3,0))&&(LIBAVCODEC_VERSION_INT>=AV_VERSION_INT(54,35,0))&&(LIBAVFORMAT_VERSION_INT>=AV_VERSION_INT(54,20,0))&&(LIBAVDEVICE_VERSION_INT>=AV_VERSION_INT(53,2,0))&&(LIBAVFILTER_VERSION_INT>=AV_VERSION_INT(3,3,0))&&(LIBSWSCALE_VERSION_INT>=AV_VERSION_INT(2,1,1)))
68
    #if ((LIBAVUTIL_VERSION_INT>=AV_VERSION_INT(53,3,0))&&(LIBAVCODEC_VERSION_INT>=AV_VERSION_INT(55,34,1))&&(LIBAVFORMAT_VERSION_INT>=AV_VERSION_INT(55,12,0))&&(LIBAVDEVICE_VERSION_INT>=AV_VERSION_INT(54,0,0))&&(LIBAVFILTER_VERSION_INT>=AV_VERSION_INT(4,2,0))&&(LIBSWSCALE_VERSION_INT>=AV_VERSION_INT(2,1,2)))
69
        #define LIBAVVERSION        "Libav 10 or higher"
70
        #define LIBAVVERSIONINT     10
71
        #include "libavresample/avresample.h"
72
        #define RESAMPLE_MAX_CHANNELS AVRESAMPLE_MAX_CHANNELS
73
        #include "libavfilter/buffersink.h"
74
        #include "libavfilter/buffersrc.h"
75
    #elif ((LIBAVUTIL_VERSION_INT>=AV_VERSION_INT(52,3,0))&&(LIBAVCODEC_VERSION_INT>=AV_VERSION_INT(54,35,0))&&(LIBAVFORMAT_VERSION_INT>=AV_VERSION_INT(54,20,0))&&(LIBAVDEVICE_VERSION_INT>=AV_VERSION_INT(53,2,0))&&(LIBAVFILTER_VERSION_INT>=AV_VERSION_INT(3,3,0))&&(LIBSWSCALE_VERSION_INT>=AV_VERSION_INT(2,1,1)))
69
        #define LIBAVVERSION        "Libav 9.x"
76
        #define LIBAVVERSION        "Libav 9.x"
70
        #define LIBAVVERSIONINT     9
77
        #define LIBAVVERSIONINT     9
71
        #include "libavresample/avresample.h"
78
        #include "libavresample/avresample.h"
Lines 110-116 Link Here
110
    #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
117
    #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
111
#endif
118
#endif
112
119
113
#if !defined(FF_API_CODEC_ID)
120
#if (LIBAVCODEC_VERSION_MAJOR < 55)
114
    #define AV_CODEC_ID_NONE        CODEC_ID_NONE
121
    #define AV_CODEC_ID_NONE        CODEC_ID_NONE
115
    #define AV_CODEC_ID_MJPEG       CODEC_ID_MJPEG
122
    #define AV_CODEC_ID_MJPEG       CODEC_ID_MJPEG
116
    #define AV_CODEC_ID_MPEG2VIDEO  CODEC_ID_MPEG2VIDEO
123
    #define AV_CODEC_ID_MPEG2VIDEO  CODEC_ID_MPEG2VIDEO
Lines 133-138 Link Here
133
    #define AV_CODEC_ID_FLAC        CODEC_ID_FLAC
140
    #define AV_CODEC_ID_FLAC        CODEC_ID_FLAC
134
    #define AV_CODEC_ID_WMAV1       CODEC_ID_WMAV1
141
    #define AV_CODEC_ID_WMAV1       CODEC_ID_WMAV1
135
    #define AV_CODEC_ID_WMAV2       CODEC_ID_WMAV2
142
    #define AV_CODEC_ID_WMAV2       CODEC_ID_WMAV2
143
    #define AV_CODEC_ID_PRORES      CODEC_ID_PRORES
144
    #define AV_CODEC_ID_MPEG1VIDEO  CODEC_ID_MPEG1VIDEO
145
    #define AV_CODEC_ID_DVVIDEO     CODEC_ID_DVVIDEO
136
#endif
146
#endif
137
147
138
#if !defined(avcodec_free_frame)
148
#if !defined(avcodec_free_frame)
(-)src/ffDiaporama/engine/_EncodeVideo.cpp (-11 / +11 lines)
Lines 136-142 Link Here
136
            av_freep(&Container->streams[i]->codec->extradata);
136
            av_freep(&Container->streams[i]->codec->extradata);
137
            av_freep(&Container->streams[i]->codec->subtitle_header);
137
            av_freep(&Container->streams[i]->codec->subtitle_header);
138
            av_freep(&Container->streams[i]->priv_data);
138
            av_freep(&Container->streams[i]->priv_data);
139
            if (Container->streams[i]->info) av_freep(&Container->streams[i]->info->duration_error);
139
            //if (Container->streams[i]->info) av_freep(&Container->streams[i]->info->duration_error);
140
        }
140
        }
141
        //=== End of patch
141
        //=== End of patch
142
        avformat_free_context(Container);
142
        avformat_free_context(Container);
Lines 151-157 Link Here
151
    if (AudioResampler) {
151
    if (AudioResampler) {
152
        #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
152
        #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
153
            audio_resample_close(AudioResampler);
153
            audio_resample_close(AudioResampler);
154
        #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
154
        #elif defined(LIBAV)
155
            avresample_close(AudioResampler);
155
            avresample_close(AudioResampler);
156
            avresample_free(&AudioResampler);
156
            avresample_free(&AudioResampler);
157
        #elif defined(FFMPEG)
157
        #elif defined(FFMPEG)
Lines 185-196 Link Here
185
int cEncodeVideo::getThreadFlags(AVCodecID ID) {
185
int cEncodeVideo::getThreadFlags(AVCodecID ID) {
186
    int Ret=0;
186
    int Ret=0;
187
    switch (ID) {
187
    switch (ID) {
188
        case CODEC_ID_PRORES:
188
        case AV_CODEC_ID_PRORES:
189
        case CODEC_ID_MPEG1VIDEO:
189
        case AV_CODEC_ID_MPEG1VIDEO:
190
        case CODEC_ID_DVVIDEO:
190
        case AV_CODEC_ID_DVVIDEO:
191
        case CODEC_ID_MPEG2VIDEO:   Ret=FF_THREAD_SLICE;                    break;
191
        case AV_CODEC_ID_MPEG2VIDEO:   Ret=FF_THREAD_SLICE;                    break;
192
        case CODEC_ID_H264 :        Ret=FF_THREAD_FRAME|FF_THREAD_SLICE;    break;
192
        case AV_CODEC_ID_H264 :        Ret=FF_THREAD_FRAME|FF_THREAD_SLICE;    break;
193
        default:                    Ret=FF_THREAD_FRAME;                    break;
193
        default:                       Ret=FF_THREAD_FRAME;                    break;
194
    }
194
    }
195
    return Ret;
195
    return Ret;
196
}
196
}
Lines 789-795 Link Here
789
                    Continue=false;
789
                    Continue=false;
790
                }
790
                }
791
            }
791
            }
792
        #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
792
        #elif defined(LIBAV)
793
            if ((AudioStream->codec->sample_fmt!=ToEncodeMusic.SampleFormat)||(AudioStream->codec->channels!=ToEncodeMusic.Channels)||(AudioSampleRate!=ToEncodeMusic.SamplingRate)) {
793
            if ((AudioStream->codec->sample_fmt!=ToEncodeMusic.SampleFormat)||(AudioStream->codec->channels!=ToEncodeMusic.Channels)||(AudioSampleRate!=ToEncodeMusic.SamplingRate)) {
794
                if (!AudioResamplerBuffer) {
794
                if (!AudioResamplerBuffer) {
795
                    int out_linesize=0;
795
                    int out_linesize=0;
Lines 857-863 Link Here
857
    }
857
    }
858
858
859
    // Define InterleaveFrame to not compute it for each frame
859
    // Define InterleaveFrame to not compute it for each frame
860
    #if defined(FFMPEG)&&(FFMPEGVERSIONINT>=201)
860
    #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=201) || (LIBAVVERSIONINT >=10))
861
    InterleaveFrame=(strcmp(Container->oformat->name,"avi")!=0);
861
    InterleaveFrame=(strcmp(Container->oformat->name,"avi")!=0);
862
    #else
862
    #else
863
    InterleaveFrame=true;
863
    InterleaveFrame=true;
Lines 1038-1044 Link Here
1038
        } else {
1038
        } else {
1039
            #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
1039
            #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
1040
                DestPacket=(u_int8_t *)PacketSound;
1040
                DestPacket=(u_int8_t *)PacketSound;
1041
            #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
1041
            #elif defined(LIBAV)
1042
                // LIBAV 9 => Convert sample format (is needed)
1042
                // LIBAV 9 => Convert sample format (is needed)
1043
                if ((AudioResampler!=NULL)&&(AudioResamplerBuffer!=NULL)) {
1043
                if ((AudioResampler!=NULL)&&(AudioResamplerBuffer!=NULL)) {
1044
                    DestPacket=AudioResamplerBuffer;
1044
                    DestPacket=AudioResamplerBuffer;
(-)src/ffDiaporama/engine/_EncodeVideo.h (-1 / +1 lines)
Lines 82-88 Link Here
82
    int                 AudioResamplerBufferSize;
82
    int                 AudioResamplerBufferSize;
83
    #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
83
    #if defined(LIBAV) && (LIBAVVERSIONINT<=8)
84
    ReSampleContext         *AudioResampler;            // Audio resampler
84
    ReSampleContext         *AudioResampler;            // Audio resampler
85
    #elif defined(LIBAV) && (LIBAVVERSIONINT<=9)
85
    #elif defined(LIBAV)
86
    AVAudioResampleContext  *AudioResampler;
86
    AVAudioResampleContext  *AudioResampler;
87
    #elif defined(FFMPEG)
87
    #elif defined(FFMPEG)
88
    SwrContext              *AudioResampler;
88
    SwrContext              *AudioResampler;
(-)src/ffDiaporama/MainWindow/mainwindow.cpp (-1 / +1 lines)
Lines 472-478 Link Here
472
    delete ApplicationConfig;
472
    delete ApplicationConfig;
473
473
474
    // Close some libav additionnals
474
    // Close some libav additionnals
475
    #if defined(LIBAV) || (defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
475
    #if (defined(LIBAV)&&(LIBAVVERSIONINT<=9) || defined(FFMPEG)&&(FFMPEGVERSIONINT<201))
476
    avfilter_uninit();
476
    avfilter_uninit();
477
    #endif
477
    #endif
478
    avformat_network_deinit();
478
    avformat_network_deinit();

Return to bug 526434