diff options
author | Martin Storsjö <martin@martin.st> | 2011-10-11 23:56:39 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2011-10-12 10:19:38 +0300 |
commit | b204c46d9d31af3d8beab359efde246d293cd676 (patch) | |
tree | eeb2d6271c59a989905216a01d9cbb20dcb06802 /libavformat | |
parent | 46c3c53baedffd34742ba93189b7e7a2b7b3e530 (diff) | |
download | ffmpeg-streaming-b204c46d9d31af3d8beab359efde246d293cd676.zip ffmpeg-streaming-b204c46d9d31af3d8beab359efde246d293cd676.tar.gz |
flvdec: Split out setting of numeric fields from storing metadata
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/flvdec.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index ad00c65..815618d 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -287,17 +287,21 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; + if (amf_type == AMF_DATA_TYPE_NUMBER) { + if (!strcmp(key, "duration")) + s->duration = num_val * AV_TIME_BASE; + else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) + vcodec->bit_rate = num_val * 1024.0; + else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) + acodec->bit_rate = num_val * 1024.0; + } + if(amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if(amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); - if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; - else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) - vcodec->bit_rate = num_val * 1024.0; - else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) - acodec->bit_rate = num_val * 1024.0; } else if (amf_type == AMF_DATA_TYPE_STRING) av_dict_set(&s->metadata, key, str_val, 0); } |