mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavc: use av_get_media_type_string and avcodec_get_name in avcodec_string.
This commit is contained in:
parent
b3be9f4a88
commit
d2d7b7134f
@ -1020,43 +1020,37 @@ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_ta
|
|||||||
|
|
||||||
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
|
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
|
||||||
{
|
{
|
||||||
|
const char *codec_type;
|
||||||
const char *codec_name;
|
const char *codec_name;
|
||||||
const char *profile = NULL;
|
const char *profile = NULL;
|
||||||
AVCodec *p;
|
AVCodec *p;
|
||||||
char buf1[32];
|
|
||||||
int bitrate;
|
int bitrate;
|
||||||
AVRational display_aspect_ratio;
|
AVRational display_aspect_ratio;
|
||||||
|
|
||||||
if (encode)
|
if (!buf || buf_size <= 0)
|
||||||
p = avcodec_find_encoder(enc->codec_id);
|
return;
|
||||||
else
|
codec_type = av_get_media_type_string(enc->codec_type);
|
||||||
p = avcodec_find_decoder(enc->codec_id);
|
codec_name = avcodec_get_name(enc->codec_id);
|
||||||
|
if (enc->profile != FF_PROFILE_UNKNOWN) {
|
||||||
if (p) {
|
p = encode ? avcodec_find_encoder(enc->codec_id) :
|
||||||
codec_name = p->name;
|
avcodec_find_decoder(enc->codec_id);
|
||||||
|
if (p)
|
||||||
profile = av_get_profile_name(p, enc->profile);
|
profile = av_get_profile_name(p, enc->profile);
|
||||||
} else if (enc->codec_id == CODEC_ID_MPEG2TS) {
|
|
||||||
/* fake mpeg2 transport stream codec (currently not
|
|
||||||
registered) */
|
|
||||||
codec_name = "mpeg2ts";
|
|
||||||
} else if (enc->codec_name[0] != '\0') {
|
|
||||||
codec_name = enc->codec_name;
|
|
||||||
} else {
|
|
||||||
/* output avi tags */
|
|
||||||
char tag_buf[32];
|
|
||||||
av_get_codec_tag_string(tag_buf, sizeof(tag_buf), enc->codec_tag);
|
|
||||||
snprintf(buf1, sizeof(buf1), "%s / 0x%04X", tag_buf, enc->codec_tag);
|
|
||||||
codec_name = buf1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(buf, buf_size, "%s: %s%s", codec_type ? codec_type : "unknown",
|
||||||
|
codec_name, enc->mb_decision ? " (hq)" : "");
|
||||||
|
buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */
|
||||||
|
if (profile)
|
||||||
|
snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", profile);
|
||||||
|
if (enc->codec_tag) {
|
||||||
|
char tag_buf[32];
|
||||||
|
av_get_codec_tag_string(tag_buf, sizeof(tag_buf), enc->codec_tag);
|
||||||
|
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
||||||
|
" (%s / 0x%04X)", tag_buf, enc->codec_tag);
|
||||||
|
}
|
||||||
switch(enc->codec_type) {
|
switch(enc->codec_type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
snprintf(buf, buf_size,
|
|
||||||
"Video: %s%s",
|
|
||||||
codec_name, enc->mb_decision ? " (hq)" : "");
|
|
||||||
if (profile)
|
|
||||||
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
|
||||||
" (%s)", profile);
|
|
||||||
if (enc->pix_fmt != PIX_FMT_NONE) {
|
if (enc->pix_fmt != PIX_FMT_NONE) {
|
||||||
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
||||||
", %s",
|
", %s",
|
||||||
@ -1089,12 +1083,6 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
snprintf(buf, buf_size,
|
|
||||||
"Audio: %s",
|
|
||||||
codec_name);
|
|
||||||
if (profile)
|
|
||||||
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
|
||||||
" (%s)", profile);
|
|
||||||
if (enc->sample_rate) {
|
if (enc->sample_rate) {
|
||||||
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
snprintf(buf + strlen(buf), buf_size - strlen(buf),
|
||||||
", %d Hz", enc->sample_rate);
|
", %d Hz", enc->sample_rate);
|
||||||
@ -1106,17 +1094,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
|
|||||||
", %s", av_get_sample_fmt_name(enc->sample_fmt));
|
", %s", av_get_sample_fmt_name(enc->sample_fmt));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_DATA:
|
|
||||||
snprintf(buf, buf_size, "Data: %s", codec_name);
|
|
||||||
break;
|
|
||||||
case AVMEDIA_TYPE_SUBTITLE:
|
|
||||||
snprintf(buf, buf_size, "Subtitle: %s", codec_name);
|
|
||||||
break;
|
|
||||||
case AVMEDIA_TYPE_ATTACHMENT:
|
|
||||||
snprintf(buf, buf_size, "Attachment: %s", codec_name);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (encode) {
|
if (encode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user