summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-06-02 10:54:45 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-06-02 10:54:45 +0000
commit7e566bbe6ce367e880bf09e293a9e72e52c0988e (patch)
tree3988b406e82bcf143d409bd5b3aa551dbcd1bdc3
parent3b963552bc8bd740c8c782778b5b1a427f268cd0 (diff)
Implement av_get_codec_tag_string() and use it in ffprobe.
Originally committed as revision 23421 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--ffprobe.c14
-rw-r--r--libavcodec/avcodec.h13
-rw-r--r--libavcodec/utils.c15
3 files changed, 29 insertions, 13 deletions
diff --git a/ffprobe.c b/ffprobe.c
index 7cb6167b05..4be5d0f875 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -120,7 +120,6 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
AVCodec *dec;
char val_str[128];
AVMetadataTag *tag = NULL;
- char a, b, c, d;
AVRational display_aspect_ratio;
printf("[STREAM]\n");
@@ -139,16 +138,9 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx)
printf("codec_time_base=%d/%d\n", dec_ctx->time_base.num, dec_ctx->time_base.den);
/* print AVI/FourCC tag */
- a = dec_ctx->codec_tag & 0xff;
- b = dec_ctx->codec_tag>>8 & 0xff;
- c = dec_ctx->codec_tag>>16 & 0xff;
- d = dec_ctx->codec_tag>>24 & 0xff;
- printf("codec_tag_string=");
- if (isprint(a)) printf("%c", a); else printf("[%d]", a);
- if (isprint(b)) printf("%c", b); else printf("[%d]", b);
- if (isprint(c)) printf("%c", c); else printf("[%d]", c);
- if (isprint(d)) printf("%c", d); else printf("[%d]", d);
- printf("\ncodec_tag=0x%04x\n", dec_ctx->codec_tag);
+ av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag);
+ printf("codec_tag_string=%s\n", val_str);
+ printf("codec_tag=0x%04x\n", dec_ctx->codec_tag);
switch (dec_ctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a07e77490c..243f34d9cb 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -30,8 +30,8 @@
#include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 72
-#define LIBAVCODEC_VERSION_MICRO 1
+#define LIBAVCODEC_VERSION_MINOR 73
+#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
@@ -3093,6 +3093,15 @@ attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
*/
unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
+/**
+ * Puts a string representing the codec tag codec_tag in buf.
+ *
+ * @param buf_size size in bytes of buf
+ * @return the length of the string that would have been generated if
+ * enough space had been available, excluding the trailing null
+ */
+size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
+
#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 60f52ac366..739e874ef8 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -802,6 +802,21 @@ static int get_bit_rate(AVCodecContext *ctx)
return bit_rate;
}
+size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
+{
+ int i, len, ret = 0;
+
+ for (i = 0; i < 4; i++) {
+ len = snprintf(buf, buf_size,
+ isprint(codec_tag&0xFF) ? "%c" : "[%d]", codec_tag&0xFF);
+ buf += len;
+ buf_size = buf_size > len ? buf_size - len : 0;
+ ret += len;
+ codec_tag>>=8;
+ }
+ return ret;
+}
+
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
{
const char *codec_name;