comparison utils.c @ 2649:1864b0a09d52 libavformat

cosmetics: moved to a separate function the code to print the characteristics of an AVStream
author nicodvb
date Sat, 20 Oct 2007 08:17:01 +0000
parents 2aea27e618ba
children 4e3d38c8896c
comparison
equal deleted inserted replaced
2648:5936e5b0d001 2649:1864b0a09d52
2482 av_freep(&s->priv_data); 2482 av_freep(&s->priv_data);
2483 return ret; 2483 return ret;
2484 } 2484 }
2485 2485
2486 /* "user interface" functions */ 2486 /* "user interface" functions */
2487 static void dump_stream_format(AVFormatContext *ic, int i, int index, char *buf, int is_output)
2488 {
2489 int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
2490 AVStream *st = ic->streams[i];
2491 int g = ff_gcd(st->time_base.num, st->time_base.den);
2492 avcodec_string(buf, sizeof(buf), st->codec, is_output);
2493 av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i);
2494 /* the pid is an important information, so we display it */
2495 /* XXX: add a generic system */
2496 if (flags & AVFMT_SHOW_IDS)
2497 av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
2498 if (strlen(st->language) > 0)
2499 av_log(NULL, AV_LOG_INFO, "(%s)", st->language);
2500 av_log(NULL, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g);
2501 av_log(NULL, AV_LOG_INFO, ": %s", buf);
2502 if(st->codec->codec_type == CODEC_TYPE_VIDEO){
2503 if(st->r_frame_rate.den && st->r_frame_rate.num)
2504 av_log(NULL, AV_LOG_INFO, ", %5.2f fps(r)", av_q2d(st->r_frame_rate));
2505 /* else if(st->time_base.den && st->time_base.num)
2506 av_log(NULL, AV_LOG_INFO, ", %5.2f fps(m)", 1/av_q2d(st->time_base));*/
2507 else
2508 av_log(NULL, AV_LOG_INFO, ", %5.2f fps(c)", 1/av_q2d(st->codec->time_base));
2509 }
2510 av_log(NULL, AV_LOG_INFO, "\n");
2511 }
2487 2512
2488 void dump_format(AVFormatContext *ic, 2513 void dump_format(AVFormatContext *ic,
2489 int index, 2514 int index,
2490 const char *url, 2515 const char *url,
2491 int is_output) 2516 int is_output)
2527 } else { 2552 } else {
2528 av_log(NULL, AV_LOG_INFO, "N/A"); 2553 av_log(NULL, AV_LOG_INFO, "N/A");
2529 } 2554 }
2530 av_log(NULL, AV_LOG_INFO, "\n"); 2555 av_log(NULL, AV_LOG_INFO, "\n");
2531 } 2556 }
2532 for(i=0;i<ic->nb_streams;i++) { 2557 for(i=0;i<ic->nb_streams;i++)
2533 AVStream *st = ic->streams[i]; 2558 dump_stream_format(ic, i, index, buf, is_output);
2534 int g= ff_gcd(st->time_base.num, st->time_base.den);
2535 avcodec_string(buf, sizeof(buf), st->codec, is_output);
2536 av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i);
2537 /* the pid is an important information, so we display it */
2538 /* XXX: add a generic system */
2539 if (is_output)
2540 flags = ic->oformat->flags;
2541 else
2542 flags = ic->iformat->flags;
2543 if (flags & AVFMT_SHOW_IDS) {
2544 av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
2545 }
2546 if (strlen(st->language) > 0) {
2547 av_log(NULL, AV_LOG_INFO, "(%s)", st->language);
2548 }
2549 av_log(NULL, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g);
2550 av_log(NULL, AV_LOG_INFO, ": %s", buf);
2551 if(st->codec->codec_type == CODEC_TYPE_VIDEO){
2552 if(st->r_frame_rate.den && st->r_frame_rate.num)
2553 av_log(NULL, AV_LOG_INFO, ", %5.2f fps(r)", av_q2d(st->r_frame_rate));
2554 /* else if(st->time_base.den && st->time_base.num)
2555 av_log(NULL, AV_LOG_INFO, ", %5.2f fps(m)", 1/av_q2d(st->time_base));*/
2556 else
2557 av_log(NULL, AV_LOG_INFO, ", %5.2f fps(c)", 1/av_q2d(st->codec->time_base));
2558 }
2559 av_log(NULL, AV_LOG_INFO, "\n");
2560 }
2561 } 2559 }
2562 2560
2563 int parse_image_size(int *width_ptr, int *height_ptr, const char *str) 2561 int parse_image_size(int *width_ptr, int *height_ptr, const char *str)
2564 { 2562 {
2565 return av_parse_video_frame_size(width_ptr, height_ptr, str); 2563 return av_parse_video_frame_size(width_ptr, height_ptr, str);