diff options
author | Clément Bœsch <ubitux@gmail.com> | 2013-06-01 15:08:00 +0200 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2013-06-01 15:12:49 +0200 |
commit | 07f6a66bf553ce02ad9e6dc7d415d3f8faa431fb (patch) | |
tree | 9a9f42f58bd67a34d5229c9ff53bd4b1dafc9372 /libavformat/webvttdec.c | |
parent | 8f75ba9926c6b1377aa746ab4ee53831a395fe41 (diff) | |
download | ffmpeg-07f6a66bf553ce02ad9e6dc7d415d3f8faa431fb.tar.gz |
lavf/webvttdec: factorize identifier and settings side data code.
Diffstat (limited to 'libavformat/webvttdec.c')
-rw-r--r-- | libavformat/webvttdec.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c index 894a762dd5..7d9910bec5 100644 --- a/libavformat/webvttdec.c +++ b/libavformat/webvttdec.c @@ -142,27 +142,19 @@ static int webvtt_read_header(AVFormatContext *s) sub->pts = ts_start; sub->duration = ts_end - ts_start; - if (identifier_len) { - uint8_t *buf = av_packet_new_side_data(sub, - AV_PKT_DATA_WEBVTT_IDENTIFIER, - identifier_len); - if (!buf) { - res = AVERROR(ENOMEM); - goto end; - } - memcpy(buf, identifier, identifier_len); - } - - if (settings_len) { - uint8_t *buf = av_packet_new_side_data(sub, - AV_PKT_DATA_WEBVTT_SETTINGS, - settings_len); - if (!buf) { - res = AVERROR(ENOMEM); - goto end; - } - memcpy(buf, settings, settings_len); - } +#define SET_SIDE_DATA(name, type) do { \ + if (name##_len) { \ + uint8_t *buf = av_packet_new_side_data(sub, type, name##_len); \ + if (!buf) { \ + res = AVERROR(ENOMEM); \ + goto end; \ + } \ + memcpy(buf, name, name##_len); \ + } \ +} while (0) + + SET_SIDE_DATA(identifier, AV_PKT_DATA_WEBVTT_IDENTIFIER); + SET_SIDE_DATA(settings, AV_PKT_DATA_WEBVTT_SETTINGS); } ff_subtitles_queue_finalize(&webvtt->q); |