Revision 72415b2a libavformat/utils.c

View differences:

libavformat/utils.c
254 254
#endif
255 255

  
256 256
enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
257
                            const char *filename, const char *mime_type, enum CodecType type){
258
    if(type == CODEC_TYPE_VIDEO){
257
                            const char *filename, const char *mime_type, enum AVMediaType type){
258
    if(type == AVMEDIA_TYPE_VIDEO){
259 259
        enum CodecID codec_id= CODEC_ID_NONE;
260 260

  
261 261
#if CONFIG_IMAGE2_MUXER
......
266 266
        if(codec_id == CODEC_ID_NONE)
267 267
            codec_id= fmt->video_codec;
268 268
        return codec_id;
269
    }else if(type == CODEC_TYPE_AUDIO)
269
    }else if(type == AVMEDIA_TYPE_AUDIO)
270 270
        return fmt->audio_codec;
271 271
    else
272 272
        return CODEC_ID_NONE;
......
351 351
               pd->buf_size, MAX_PROBE_PACKETS - st->probe_packets, fmt->name, score);
352 352
        if (!strcmp(fmt->name, "mp3")) {
353 353
            st->codec->codec_id = CODEC_ID_MP3;
354
            st->codec->codec_type = CODEC_TYPE_AUDIO;
354
            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
355 355
        } else if (!strcmp(fmt->name, "ac3")) {
356 356
            st->codec->codec_id = CODEC_ID_AC3;
357
            st->codec->codec_type = CODEC_TYPE_AUDIO;
357
            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
358 358
        } else if (!strcmp(fmt->name, "eac3")) {
359 359
            st->codec->codec_id = CODEC_ID_EAC3;
360
            st->codec->codec_type = CODEC_TYPE_AUDIO;
360
            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
361 361
        } else if (!strcmp(fmt->name, "mpegvideo")) {
362 362
            st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
363
            st->codec->codec_type = CODEC_TYPE_VIDEO;
363
            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
364 364
        } else if (!strcmp(fmt->name, "m4v")) {
365 365
            st->codec->codec_id = CODEC_ID_MPEG4;
366
            st->codec->codec_type = CODEC_TYPE_VIDEO;
366
            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
367 367
        } else if (!strcmp(fmt->name, "h264")) {
368 368
            st->codec->codec_id = CODEC_ID_H264;
369
            st->codec->codec_type = CODEC_TYPE_VIDEO;
369
            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
370 370
        } else if (!strcmp(fmt->name, "dts")) {
371 371
            st->codec->codec_id = CODEC_ID_DTS;
372
            st->codec->codec_type = CODEC_TYPE_AUDIO;
372
            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
373 373
        }
374 374
    }
375 375
    return !!fmt;
......
646 646
        st= s->streams[pkt->stream_index];
647 647

  
648 648
        switch(st->codec->codec_type){
649
        case CODEC_TYPE_VIDEO:
649
        case AVMEDIA_TYPE_VIDEO:
650 650
            if(s->video_codec_id)   st->codec->codec_id= s->video_codec_id;
651 651
            break;
652
        case CODEC_TYPE_AUDIO:
652
        case AVMEDIA_TYPE_AUDIO:
653 653
            if(s->audio_codec_id)   st->codec->codec_id= s->audio_codec_id;
654 654
            break;
655
        case CODEC_TYPE_SUBTITLE:
655
        case AVMEDIA_TYPE_SUBTITLE:
656 656
            if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id;
657 657
            break;
658 658
        }
......
729 729
    *pnum = 0;
730 730
    *pden = 0;
731 731
    switch(st->codec->codec_type) {
732
    case CODEC_TYPE_VIDEO:
732
    case AVMEDIA_TYPE_VIDEO:
733 733
        if(st->time_base.num*1000LL > st->time_base.den){
734 734
            *pnum = st->time_base.num;
735 735
            *pden = st->time_base.den;
......
741 741
            }
742 742
        }
743 743
        break;
744
    case CODEC_TYPE_AUDIO:
744
    case AVMEDIA_TYPE_AUDIO:
745 745
        frame_size = get_audio_frame_size(st->codec, pkt->size);
746 746
        if (frame_size < 0)
747 747
            break;
......
754 754
}
755 755

  
756 756
static int is_intra_only(AVCodecContext *enc){
757
    if(enc->codec_type == CODEC_TYPE_AUDIO){
757
    if(enc->codec_type == AVMEDIA_TYPE_AUDIO){
758 758
        return 1;
759
    }else if(enc->codec_type == CODEC_TYPE_VIDEO){
759
    }else if(enc->codec_type == AVMEDIA_TYPE_VIDEO){
760 760
        switch(enc->codec_id){
761 761
        case CODEC_ID_MJPEG:
762 762
        case CODEC_ID_MJPEGB:
......
1223 1223
        return -1;
1224 1224
    for(i = 0; i < s->nb_streams; i++) {
1225 1225
        st = s->streams[i];
1226
        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
1226
        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
1227 1227
            return i;
1228 1228
        }
1229
        if (first_audio_index < 0 && st->codec->codec_type == CODEC_TYPE_AUDIO)
1229
        if (first_audio_index < 0 && st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
1230 1230
            first_audio_index = i;
1231 1231
    }
1232 1232
    return first_audio_index >= 0 ? first_audio_index : 0;
......
1953 1953
{
1954 1954
    int val;
1955 1955
    switch(enc->codec_type) {
1956
    case CODEC_TYPE_AUDIO:
1956
    case AVMEDIA_TYPE_AUDIO:
1957 1957
        val = enc->sample_rate && enc->channels && enc->sample_fmt != SAMPLE_FMT_NONE;
1958 1958
        if(!enc->frame_size &&
1959 1959
           (enc->codec_id == CODEC_ID_VORBIS ||
......
1964 1964
            enc->codec_id == CODEC_ID_SPEEX))
1965 1965
            return 0;
1966 1966
        break;
1967
    case CODEC_TYPE_VIDEO:
1967
    case AVMEDIA_TYPE_VIDEO:
1968 1968
        val = enc->width && enc->pix_fmt != PIX_FMT_NONE;
1969 1969
        break;
1970 1970
    default:
......
1992 1992

  
1993 1993
    if(!has_codec_parameters(st->codec)){
1994 1994
        switch(st->codec->codec_type) {
1995
        case CODEC_TYPE_VIDEO:
1995
        case AVMEDIA_TYPE_VIDEO:
1996 1996
            avcodec_get_frame_defaults(&picture);
1997 1997
            ret = avcodec_decode_video2(st->codec, &picture,
1998 1998
                                        &got_picture, avpkt);
1999 1999
            break;
2000
        case CODEC_TYPE_AUDIO:
2000
        case AVMEDIA_TYPE_AUDIO:
2001 2001
            data_size = FFMAX(avpkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE);
2002 2002
            samples = av_malloc(data_size);
2003 2003
            if (!samples)
......
2129 2129
            st->codec->frame_size = 0;
2130 2130
            st->codec->channels = 0;
2131 2131
        }
2132
        if(st->codec->codec_type == CODEC_TYPE_VIDEO){
2132
        if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
2133 2133
/*            if(!st->time_base.num)
2134 2134
                st->time_base= */
2135 2135
            if(!st->codec->time_base.num)
......
2171 2171
                break;
2172 2172
            /* variable fps and no guess at the real fps */
2173 2173
            if(   tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num)
2174
               && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO)
2174
               && duration_count[i]<20 && st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
2175 2175
                break;
2176 2176
            if(st->parser && st->parser->parser->split && !st->codec->extradata)
2177 2177
                break;
......
2243 2243
            if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){
2244 2244
                double dur= duration * av_q2d(st->time_base);
2245 2245

  
2246
//                if(st->codec->codec_type == CODEC_TYPE_VIDEO)
2246
//                if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
2247 2247
//                    av_log(NULL, AV_LOG_ERROR, "%f\n", dur);
2248 2248
                if(duration_count[index] < 2)
2249 2249
                    memset(duration_error[index], 0, sizeof(*duration_error));
......
2293 2293
            av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
2294 2294
                     (st->codec_info_nb_frames-2)*(int64_t)st->time_base.den,
2295 2295
                      codec_info_duration[i]    *(int64_t)st->time_base.num, 60000);
2296
        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
2296
        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
2297 2297
            if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample)
2298 2298
                st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
2299 2299

  
......
2312 2312

  
2313 2313
                for(j=1; j<MAX_STD_TIMEBASES; j++){
2314 2314
                    double error= duration_error[i][j] * get_std_framerate(j);
2315
//                    if(st->codec->codec_type == CODEC_TYPE_VIDEO)
2315
//                    if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
2316 2316
//                        av_log(NULL, AV_LOG_ERROR, "%f %f\n", get_std_framerate(j) / 12.0/1001, error);
2317 2317
                    if(error < best_error){
2318 2318
                        best_error= error;
......
2334 2334
                    st->r_frame_rate.den = st->time_base.num;
2335 2335
                }
2336 2336
            }
2337
        }else if(st->codec->codec_type == CODEC_TYPE_AUDIO) {
2337
        }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
2338 2338
            if(!st->codec->bits_per_coded_sample)
2339 2339
                st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id);
2340 2340
        }
......
2348 2348
    /* correct DTS for B-frame streams with no timestamps */
2349 2349
    for(i=0;i<ic->nb_streams;i++) {
2350 2350
        st = ic->streams[i];
2351
        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
2351
        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
2352 2352
            if(b-frames){
2353 2353
                ppktl = &ic->packet_buffer;
2354 2354
                while(ppkt1){
......
2581 2581
        st = s->streams[i];
2582 2582

  
2583 2583
        switch (st->codec->codec_type) {
2584
        case CODEC_TYPE_AUDIO:
2584
        case AVMEDIA_TYPE_AUDIO:
2585 2585
            if(st->codec->sample_rate<=0){
2586 2586
                av_log(s, AV_LOG_ERROR, "sample rate not set\n");
2587 2587
                return -1;
......
2590 2590
                st->codec->block_align = st->codec->channels *
2591 2591
                    av_get_bits_per_sample(st->codec->codec_id) >> 3;
2592 2592
            break;
2593
        case CODEC_TYPE_VIDEO:
2593
        case AVMEDIA_TYPE_VIDEO:
2594 2594
            if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){ //FIXME audio too?
2595 2595
                av_log(s, AV_LOG_ERROR, "time base not set\n");
2596 2596
                return -1;
......
2658 2658
        st = s->streams[i];
2659 2659

  
2660 2660
        switch (st->codec->codec_type) {
2661
        case CODEC_TYPE_AUDIO:
2661
        case AVMEDIA_TYPE_AUDIO:
2662 2662
            den = (int64_t)st->time_base.num * st->codec->sample_rate;
2663 2663
            break;
2664
        case CODEC_TYPE_VIDEO:
2664
        case AVMEDIA_TYPE_VIDEO:
2665 2665
            den = (int64_t)st->time_base.num * st->codec->time_base.den;
2666 2666
            break;
2667 2667
        default:
......
2732 2732

  
2733 2733
    /* update pts */
2734 2734
    switch (st->codec->codec_type) {
2735
    case CODEC_TYPE_AUDIO:
2735
    case AVMEDIA_TYPE_AUDIO:
2736 2736
        frame_size = get_audio_frame_size(st->codec, pkt->size);
2737 2737

  
2738 2738
        /* HACK/FIXME, we skip the initial 0 size packets as they are most
......
2742 2742
            av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size);
2743 2743
        }
2744 2744
        break;
2745
    case CODEC_TYPE_VIDEO:
2745
    case AVMEDIA_TYPE_VIDEO:
2746 2746
        av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num);
2747 2747
        break;
2748 2748
    default:
......
2859 2859
    AVStream *st= s->streams[ pkt->stream_index];
2860 2860

  
2861 2861
    //FIXME/XXX/HACK drop zero sized packets
2862
    if(st->codec->codec_type == CODEC_TYPE_AUDIO && pkt->size==0)
2862
    if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size==0)
2863 2863
        return 0;
2864 2864

  
2865 2865
//av_log(NULL, AV_LOG_DEBUG, "av_interleaved_write_frame %d %"PRId64" %"PRId64"\n", pkt->size, pkt->dts, pkt->pts);
......
2999 2999
                 st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
3000 3000
                 display_aspect_ratio.num, display_aspect_ratio.den);
3001 3001
    }
3002
    if(st->codec->codec_type == CODEC_TYPE_VIDEO){
3002
    if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
3003 3003
        if(st->avg_frame_rate.den && st->avg_frame_rate.num)
3004 3004
            print_fps(av_q2d(st->avg_frame_rate), "fps");
3005 3005
        if(st->r_frame_rate.den && st->r_frame_rate.num)

Also available in: Unified diff