Revision 01f4895c ffplay.c

View differences:

ffplay.c
381 381
    vp = &is->pictq[is->pictq_rindex];
382 382
    if (vp->bmp) {
383 383
        /* XXX: use variable in the frame */
384
        if (is->video_st->codec.sample_aspect_ratio.num == 0) 
384
        if (is->video_st->codec->sample_aspect_ratio.num == 0) 
385 385
            aspect_ratio = 0;
386 386
        else
387
            aspect_ratio = av_q2d(is->video_st->codec.sample_aspect_ratio) 
388
                * is->video_st->codec.width / is->video_st->codec.height;;
387
            aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio) 
388
                * is->video_st->codec->width / is->video_st->codec->height;;
389 389
        if (aspect_ratio <= 0.0)
390
            aspect_ratio = (float)is->video_st->codec.width / 
391
                (float)is->video_st->codec.height;
390
            aspect_ratio = (float)is->video_st->codec->width / 
391
                (float)is->video_st->codec->height;
392 392
        /* if an active format is indicated, then it overrides the
393 393
           mpeg format */
394 394
#if 0
395
        if (is->video_st->codec.dtg_active_format != is->dtg_active_format) {
396
            is->dtg_active_format = is->video_st->codec.dtg_active_format;
395
        if (is->video_st->codec->dtg_active_format != is->dtg_active_format) {
396
            is->dtg_active_format = is->video_st->codec->dtg_active_format;
397 397
            printf("dtg_active_format=%d\n", is->dtg_active_format);
398 398
        }
399 399
#endif
400 400
#if 0
401
        switch(is->video_st->codec.dtg_active_format) {
401
        switch(is->video_st->codec->dtg_active_format) {
402 402
        case FF_DTG_AFD_SAME:
403 403
        default:
404 404
            /* nothing to do */
......
469 469
    int16_t time_diff;
470 470
    
471 471
    /* compute display index : center on currently output samples */
472
    channels = s->audio_st->codec.channels;
472
    channels = s->audio_st->codec->channels;
473 473
    nb_display_channels = channels;
474 474
    if (!s->paused) {
475 475
        n = 2 * channels;
......
480 480
           the last buffer computation */
481 481
        if (audio_callback_time) {
482 482
            time_diff = av_gettime() - audio_callback_time;
483
            delay += (time_diff * s->audio_st->codec.sample_rate) / 1000000;
483
            delay += (time_diff * s->audio_st->codec->sample_rate) / 1000000;
484 484
        }
485 485
        
486 486
        delay -= s->width / 2;
......
567 567
    hw_buf_size = audio_write_get_buf_size(is);
568 568
    bytes_per_sec = 0;
569 569
    if (is->audio_st) {
570
        bytes_per_sec = is->audio_st->codec.sample_rate * 
571
            2 * is->audio_st->codec.channels;
570
        bytes_per_sec = is->audio_st->codec->sample_rate * 
571
            2 * is->audio_st->codec->channels;
572 572
    }
573 573
    if (bytes_per_sec)
574 574
        pts -= (double)hw_buf_size / bytes_per_sec;
......
767 767
#if 0
768 768
    /* XXX: use generic function */
769 769
    /* XXX: disable overlay if no hardware acceleration or if RGB format */
770
    switch(is->video_st->codec.pix_fmt) {
770
    switch(is->video_st->codec->pix_fmt) {
771 771
    case PIX_FMT_YUV420P:
772 772
    case PIX_FMT_YUV422P:
773 773
    case PIX_FMT_YUV444P:
......
781 781
        break;
782 782
    }
783 783
#endif
784
    vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec.width,
785
                                   is->video_st->codec.height,
784
    vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec->width,
785
                                   is->video_st->codec->height,
786 786
                                   SDL_YV12_OVERLAY, 
787 787
                                   screen);
788
    vp->width = is->video_st->codec.width;
789
    vp->height = is->video_st->codec.height;
788
    vp->width = is->video_st->codec->width;
789
    vp->height = is->video_st->codec->height;
790 790

  
791 791
    SDL_LockMutex(is->pictq_mutex);
792 792
    vp->allocated = 1;
......
815 815

  
816 816
    /* alloc or resize hardware picture buffer */
817 817
    if (!vp->bmp || 
818
        vp->width != is->video_st->codec.width ||
819
        vp->height != is->video_st->codec.height) {
818
        vp->width != is->video_st->codec->width ||
819
        vp->height != is->video_st->codec->height) {
820 820
        SDL_Event event;
821 821

  
822 822
        vp->allocated = 0;
......
852 852
        pict.linesize[1] = vp->bmp->pitches[2];
853 853
        pict.linesize[2] = vp->bmp->pitches[1];
854 854
        img_convert(&pict, dst_pix_fmt, 
855
                    (AVPicture *)src_frame, is->video_st->codec.pix_fmt, 
856
                    is->video_st->codec.width, is->video_st->codec.height);
855
                    (AVPicture *)src_frame, is->video_st->codec->pix_fmt, 
856
                    is->video_st->codec->width, is->video_st->codec->height);
857 857
        /* update the bitmap content */
858 858
        SDL_UnlockYUVOverlay(vp->bmp);
859 859

  
......
883 883
        pts = is->video_clock;
884 884
    }
885 885
    /* update video clock for next frame */
886
    frame_delay = av_q2d(is->video_st->codec.time_base);
886
    frame_delay = av_q2d(is->video_st->codec->time_base);
887 887
    /* for MPEG2, the frame can be repeated, so we update the
888 888
       clock accordingly */
889 889
    if (src_frame->repeat_pict) {
......
928 928
            pts = av_q2d(is->video_st->time_base)*pkt->dts;
929 929

  
930 930
            SDL_LockMutex(is->video_decoder_mutex);
931
            len1 = avcodec_decode_video(&is->video_st->codec, 
931
            len1 = avcodec_decode_video(is->video_st->codec, 
932 932
                                        frame, &got_picture, 
933 933
                                        pkt->data, pkt->size);
934 934
            SDL_UnlockMutex(is->video_decoder_mutex);
......
953 953
{
954 954
    int size, len, channels;
955 955

  
956
    channels = is->audio_st->codec.channels;
956
    channels = is->audio_st->codec->channels;
957 957

  
958 958
    size = samples_size / sizeof(short);
959 959
    while (size > 0) {
......
977 977
    int n, samples_size;
978 978
    double ref_clock;
979 979
    
980
    n = 2 * is->audio_st->codec.channels;
980
    n = 2 * is->audio_st->codec->channels;
981 981
    samples_size = samples_size1;
982 982

  
983 983
    /* if not master, then we try to remove or add samples to correct the clock */
......
999 999
                avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
1000 1000

  
1001 1001
                if (fabs(avg_diff) >= is->audio_diff_threshold) {
1002
                    wanted_size = samples_size + ((int)(diff * is->audio_st->codec.sample_rate) * n);
1002
                    wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
1003 1003
                    nb_samples = samples_size / n;
1004 1004
                
1005 1005
                    min_size = ((nb_samples * (100 - SAMPLE_CORRECTION_PERCENT_MAX)) / 100) * n;
......
1057 1057
        /* NOTE: the audio packet can contain several frames */
1058 1058
        while (is->audio_pkt_size > 0) {
1059 1059
            SDL_LockMutex(is->audio_decoder_mutex);
1060
            len1 = avcodec_decode_audio(&is->audio_st->codec, 
1060
            len1 = avcodec_decode_audio(is->audio_st->codec, 
1061 1061
                                        (int16_t *)audio_buf, &data_size, 
1062 1062
                                        is->audio_pkt_data, is->audio_pkt_size);
1063 1063
            SDL_UnlockMutex(is->audio_decoder_mutex);
......
1074 1074
            /* if no pts, then compute it */
1075 1075
            pts = is->audio_clock;
1076 1076
            *pts_ptr = pts;
1077
            n = 2 * is->audio_st->codec.channels;
1077
            n = 2 * is->audio_st->codec->channels;
1078 1078
            is->audio_clock += (double)data_size / 
1079
                (double)(n * is->audio_st->codec.sample_rate);
1079
                (double)(n * is->audio_st->codec->sample_rate);
1080 1080
#if defined(DEBUG_SYNC)
1081 1081
            {
1082 1082
                static double last_clock;
......
1164 1164

  
1165 1165
    if (stream_index < 0 || stream_index >= ic->nb_streams)
1166 1166
        return -1;
1167
    enc = &ic->streams[stream_index]->codec;
1167
    enc = ic->streams[stream_index]->codec;
1168 1168
    
1169 1169
    /* prepare audio output */
1170 1170
    if (enc->codec_type == CODEC_TYPE_AUDIO) {
......
1248 1248
    AVFormatContext *ic = is->ic;
1249 1249
    AVCodecContext *enc;
1250 1250
    
1251
    enc = &ic->streams[stream_index]->codec;
1251
    enc = ic->streams[stream_index]->codec;
1252 1252

  
1253 1253
    switch(enc->codec_type) {
1254 1254
    case CODEC_TYPE_AUDIO:
......
1387 1387
    }
1388 1388

  
1389 1389
    for(i = 0; i < ic->nb_streams; i++) {
1390
        AVCodecContext *enc = &ic->streams[i]->codec;
1390
        AVCodecContext *enc = ic->streams[i]->codec;
1391 1391
        switch(enc->codec_type) {
1392 1392
        case CODEC_TYPE_AUDIO:
1393 1393
            if (audio_index < 0 && !audio_disable)
......
1455 1455
                }
1456 1456
                if (is->video_stream >= 0) {
1457 1457
                    packet_queue_flush(&is->videoq);
1458
                    avcodec_flush_buffers(&ic->streams[video_index]->codec);
1458
                    avcodec_flush_buffers(ic->streams[video_index]->codec);
1459 1459
                }
1460 1460
            }
1461 1461
            SDL_UnlockMutex(is->audio_decoder_mutex);
......
1594 1594
        if (stream_index == start_index)
1595 1595
            return;
1596 1596
        st = ic->streams[stream_index];
1597
        if (st->codec.codec_type == codec_type) {
1597
        if (st->codec->codec_type == codec_type) {
1598 1598
            /* check that parameters are OK */
1599 1599
            switch(codec_type) {
1600 1600
            case CODEC_TYPE_AUDIO:
1601
                if (st->codec.sample_rate != 0 &&
1602
                    st->codec.channels != 0)
1601
                if (st->codec->sample_rate != 0 &&
1602
                    st->codec->channels != 0)
1603 1603
                    goto the_end;
1604 1604
                break;
1605 1605
            case CODEC_TYPE_VIDEO:

Also available in: Unified diff