Browse Source

lavf/webvttdec: factorize identifier and settings side data code.

tags/n2.0
Clément Bœsch 12 years ago
parent
commit
07f6a66bf5
1 changed files with 13 additions and 21 deletions
  1. +13
    -21
      libavformat/webvttdec.c

+ 13
- 21
libavformat/webvttdec.c View File

@@ -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);


Loading…
Cancel
Save