[FFmpeg-cvslog] avformat/asfdec_f: Add ASFDataType, use named types for metadata
John Adlum
git at videolan.org
Thu Jul 2 05:15:56 CEST 2015
ffmpeg | branch: master | John Adlum <john.adlum at nospam> | Thu Jul 2 00:15:13 2015 +0200| [72cad800164c169bc0fdc48a24b4503035e81ed2] | committer: Michael Niedermayer
avformat/asfdec_f: Add ASFDataType, use named types for metadata
This is based on asfdec_o.c, but uses a proper type instead of defines
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72cad800164c169bc0fdc48a24b4503035e81ed2
---
libavformat/asf.h | 10 ++++++++++
libavformat/asfdec_f.c | 20 ++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 0789b17..f98fc46 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -28,6 +28,16 @@
#define PACKET_SIZE 3200
+typedef enum ASFDataType {
+ ASF_UNICODE = 0,
+ ASF_BYTE_ARRAY = 1,
+ ASF_BOOL = 2,
+ ASF_DWORD = 3,
+ ASF_QWORD = 4,
+ ASF_WORD = 5,
+ ASF_GUID = 6,
+}ASFDataType;
+
typedef struct ASFMainHeader {
ff_asf_guid guid; ///< generated by client computer
uint64_t file_size; /**< in bytes
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index baa7c18..500c5f0 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -327,12 +327,15 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len, int
if (!value)
goto finish;
- if (type == 0) { // UTF16-LE
+ switch (type) {
+ case ASF_UNICODE:
avio_get_str16le(s->pb, len, value, 2 * len + 1);
- } else if (type == -1) { // ASCII
+ break;
+ case -1: // ASCI
avio_read(s->pb, value, len);
value[len]=0;
- } else if (type == 1) { // byte array
+ break;
+ case ASF_BYTE_ARRAY:
if (!strcmp(key, "WM/Picture")) { // handle cover art
asf_read_picture(s, len);
} else if (!strcmp(key, "ID3")) { // handle ID3 tag
@@ -341,13 +344,18 @@ static void get_tag(AVFormatContext *s, const char *key, int type, int len, int
av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key);
}
goto finish;
- } else if (type > 1 && type <= 5) { // boolean or DWORD or QWORD or WORD
+ case ASF_BOOL:
+ case ASF_DWORD:
+ case ASF_QWORD:
+ case ASF_WORD: {
uint64_t num = get_value(s->pb, type, type2_size);
snprintf(value, LEN, "%"PRIu64, num);
- } else if (type == 6) { // (don't) handle GUID
+ break;
+ }
+ case ASF_GUID:
av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key);
goto finish;
- } else {
+ default:
av_log(s, AV_LOG_DEBUG,
"Unsupported value type %d in tag %s.\n", type, key);
goto finish;
More information about the ffmpeg-cvslog
mailing list