| 802 | } |
| 803 | |
| 804 | void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) |
| 805 | { |
| 806 | const char *codec_name; |
| 807 | AVCodec *p; |
| 808 | char buf1[32]; |
| 809 | int bitrate; |
| 810 | AVRational display_aspect_ratio; |
| 811 | |
| 812 | if (encode) |
| 813 | p = avcodec_find_encoder(enc->codec_id); |
| 814 | else |
| 815 | p = avcodec_find_decoder(enc->codec_id); |
| 816 | |
| 817 | if (p) { |
| 818 | codec_name = p->name; |
| 819 | } else if (enc->codec_id == CODEC_ID_MPEG2TS) { |
| 820 | /* fake mpeg2 transport stream codec (currently not |
| 821 | registered) */ |
| 822 | codec_name = "mpeg2ts"; |
| 823 | } else if (enc->codec_name[0] != '\0') { |
| 824 | codec_name = enc->codec_name; |
| 825 | } else { |
| 826 | /* output avi tags */ |
| 827 | if( isprint(enc->codec_tag&0xFF) && isprint((enc->codec_tag>>8)&0xFF) |
| 828 | && isprint((enc->codec_tag>>16)&0xFF) && isprint((enc->codec_tag>>24)&0xFF)){ |
| 829 | snprintf(buf1, sizeof(buf1), "%c%c%c%c / 0x%04X", |
| 830 | enc->codec_tag & 0xff, |
| 831 | (enc->codec_tag >> 8) & 0xff, |
| 832 | (enc->codec_tag >> 16) & 0xff, |
| 833 | (enc->codec_tag >> 24) & 0xff, |
| 834 | enc->codec_tag); |
| 835 | } else { |
| 836 | snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag); |
| 837 | } |
| 838 | codec_name = buf1; |
| 839 | } |
| 840 | |
| 841 | switch(enc->codec_type) { |
| 842 | case AVMEDIA_TYPE_VIDEO: |
| 843 | snprintf(buf, buf_size, |
| 844 | "Video: %s%s", |
| 845 | codec_name, enc->mb_decision ? " (hq)" : ""); |
| 846 | if (enc->pix_fmt != PIX_FMT_NONE) { |
| 847 | snprintf(buf + strlen(buf), buf_size - strlen(buf), |
| 848 | ", %s", |
| 849 | avcodec_get_pix_fmt_name(enc->pix_fmt)); |
| 850 | } |
| 851 | if (enc->width) { |
| 852 | snprintf(buf + strlen(buf), buf_size - strlen(buf), |
| 853 | ", %dx%d", |
| 854 | enc->width, enc->height); |
| 855 | if (enc->sample_aspect_ratio.num) { |
| 856 | av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, |
| 857 | enc->width*enc->sample_aspect_ratio.num, |
| 858 | enc->height*enc->sample_aspect_ratio.den, |
| 859 | 1024*1024); |
| 860 | snprintf(buf + strlen(buf), buf_size - strlen(buf), |
| 861 | " [PAR %d:%d DAR %d:%d]", |
no test coverage detected