diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index 3c52040bce..bd20c40d15 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -106,6 +106,11 @@ static SchroBuffer *FindNextSchroParseUnit(SchroParseUnitContext *parse_ctx) return NULL; in_buf = av_malloc(next_pu_offset); + if (!in_buf) { + av_log(parse_ctx, AV_LOG_ERROR, "Unable to allocate input buffer\n"); + return NULL; + } + memcpy(in_buf, parse_ctx->buf, next_pu_offset); enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset); enc_buf->free = libschroedinger_decode_buffer_free; diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 2f57c55e5b..45a8bad37e 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -785,8 +785,12 @@ int avio_open2(AVIOContext **s, const char *filename, int flags, int avio_close(AVIOContext *s) { - URLContext *h = s->opaque; + URLContext *h; + if (!s) + return 0; + + h = s->opaque; av_free(s->buffer); av_free(s); return ffurl_close(h); diff --git a/libavformat/mov.c b/libavformat/mov.c index 2f48f2e7ec..5a0353107b 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -596,6 +596,34 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + AVStream *st; + int eac3info, acmod, lfeon, bsmod; + + if (c->fc->nb_streams < 1) + return 0; + st = c->fc->streams[c->fc->nb_streams-1]; + + /* No need to parse fields for additional independent substreams and its + * associated dependent substreams since libavcodec's E-AC-3 decoder + * does not support them yet. */ + avio_rb16(pb); /* data_rate and num_ind_sub */ + eac3info = avio_rb24(pb); + bsmod = (eac3info >> 12) & 0x1f; + acmod = (eac3info >> 9) & 0x7; + lfeon = (eac3info >> 8) & 0x1; + st->codec->channel_layout = avpriv_ac3_channel_layout_tab[acmod]; + if (lfeon) + st->codec->channel_layout |= AV_CH_LOW_FREQUENCY; + st->codec->channels = av_get_channel_layout_nb_channels(st->codec->channel_layout); + st->codec->audio_service_type = bsmod; + if (st->codec->channels > 1 && bsmod == 0x7) + st->codec->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE; + + return 0; +} + static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -2605,6 +2633,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('w','a','v','e'), mov_read_wave }, { MKTAG('e','s','d','s'), mov_read_esds }, { MKTAG('d','a','c','3'), mov_read_dac3 }, /* AC-3 info */ +{ MKTAG('d','e','c','3'), mov_read_dec3 }, /* EAC-3 info */ { MKTAG('w','i','d','e'), mov_read_wide }, /* place holder */ { MKTAG('w','f','e','x'), mov_read_wfex }, { MKTAG('c','m','o','v'), mov_read_cmov }, diff --git a/libavformat/segment.c b/libavformat/segment.c index 05f76a72c5..09949d7aeb 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -113,10 +113,15 @@ static int seg_write_header(AVFormatContext *s) seg->offset_time = 0; seg->recording_time = seg->time * 1000000; + oc = avformat_alloc_context(); + + if (!oc) + return AVERROR(ENOMEM); + if (seg->list) if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) - return ret; + goto fail; for (i = 0; i< s->nb_streams; i++) seg->has_video += @@ -127,13 +132,6 @@ static int seg_write_header(AVFormatContext *s) "More than a single video stream present, " "expect issues decoding it.\n"); - oc = avformat_alloc_context(); - - if (!oc) { - ret = AVERROR(ENOMEM); - goto fail; - } - oc->oformat = av_guess_format(seg->format, s->filename, NULL); if (!oc->oformat) {