Commit fa851185 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  mov_chan: Pass a separate AVIOContext for reading
  af_asyncts: check return value from lavr when flushing.
  mss2: simplify loop in decode_rle()
  mss12: avoid unnecessary division in arith*_get_bit()
  mss2: do not try to read too many palette entries
  mpegvideo: set AVFrame fields to NULL after freeing the base memory
  configure: Set the right cc_e flags for msvc
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents a7fbc7d7 9afb7061
...@@ -2590,6 +2590,7 @@ probe_cc(){ ...@@ -2590,6 +2590,7 @@ probe_cc(){
_ld_o='-Fe$@' _ld_o='-Fe$@'
fi fi
_cc_o='-Fo $@' _cc_o='-Fo $@'
_cc_e='-P -Fi $@'
_flags_filter=msvc_flags _flags_filter=msvc_flags
_ld_lib='lib%.a' _ld_lib='lib%.a'
_ld_path='-libpath:' _ld_path='-libpath:'
......
...@@ -393,13 +393,16 @@ static void free_picture(MpegEncContext *s, Picture *pic) ...@@ -393,13 +393,16 @@ static void free_picture(MpegEncContext *s, Picture *pic)
av_freep(&pic->mb_mean); av_freep(&pic->mb_mean);
av_freep(&pic->f.mbskip_table); av_freep(&pic->f.mbskip_table);
av_freep(&pic->qscale_table_base); av_freep(&pic->qscale_table_base);
pic->f.qscale_table = NULL;
av_freep(&pic->mb_type_base); av_freep(&pic->mb_type_base);
pic->f.mb_type = NULL;
av_freep(&pic->f.dct_coeff); av_freep(&pic->f.dct_coeff);
av_freep(&pic->f.pan_scan); av_freep(&pic->f.pan_scan);
pic->f.mb_type = NULL; pic->f.mb_type = NULL;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
av_freep(&pic->motion_val_base[i]); av_freep(&pic->motion_val_base[i]);
av_freep(&pic->f.ref_index[i]); av_freep(&pic->f.ref_index[i]);
pic->f.motion_val[i] = NULL;
} }
if (pic->f.type == FF_BUFFER_TYPE_SHARED) { if (pic->f.type == FF_BUFFER_TYPE_SHARED) {
......
...@@ -103,7 +103,7 @@ av_cold int ff_mss12_decode_end(MSS12Context *ctx); ...@@ -103,7 +103,7 @@ av_cold int ff_mss12_decode_end(MSS12Context *ctx);
static int arith ## VERSION ## _get_bit(ArithCoder *c) \ static int arith ## VERSION ## _get_bit(ArithCoder *c) \
{ \ { \
int range = c->high - c->low + 1; \ int range = c->high - c->low + 1; \
int bit = (((c->value - c->low) << 1) + 1) / range; \ int bit = 2 * c->value - c->low >= c->high; \
\ \
if (bit) \ if (bit) \
c->low += range >> 1; \ c->low += range >> 1; \
......
...@@ -161,7 +161,7 @@ static int decode_pal_v2(MSS12Context *ctx, const uint8_t *buf, int buf_size) ...@@ -161,7 +161,7 @@ static int decode_pal_v2(MSS12Context *ctx, const uint8_t *buf, int buf_size)
return 0; return 0;
ncol = *buf++; ncol = *buf++;
if (buf_size < 2 + ncol * 3) if (ncol > ctx->free_colours || buf_size < 2 + ncol * 3)
return -1; return -1;
for (i = 0; i < ncol; i++) for (i = 0; i < ncol; i++)
*pal++ = AV_RB24(buf + 3 * i); *pal++ = AV_RB24(buf + 3 * i);
...@@ -335,8 +335,7 @@ static int decode_rle(GetBitContext *gb, uint8_t *pal_dst, int pal_stride, ...@@ -335,8 +335,7 @@ static int decode_rle(GetBitContext *gb, uint8_t *pal_dst, int pal_stride,
else else
repeat = get_bits(gb, b); repeat = get_bits(gb, b);
while (b--) repeat += (1 << b) - 1;
repeat += 1 << b;
if (last_symbol == -2) { if (last_symbol == -2) {
int skip = FFMIN(repeat, pal_dst + w - pp); int skip = FFMIN(repeat, pal_dst + w - pp);
......
...@@ -127,8 +127,13 @@ static int request_frame(AVFilterLink *link) ...@@ -127,8 +127,13 @@ static int request_frame(AVFilterLink *link)
nb_samples); nb_samples);
if (!buf) if (!buf)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
avresample_convert(s->avr, (void**)buf->extended_data, buf->linesize[0], ret = avresample_convert(s->avr, (void**)buf->extended_data,
nb_samples, NULL, 0, 0); buf->linesize[0], nb_samples, NULL, 0, 0);
if (ret <= 0) {
avfilter_unref_bufferp(&buf);
return (ret < 0) ? ret : AVERROR_EOF;
}
buf->pts = s->pts; buf->pts = s->pts;
return ff_filter_samples(link, buf); return ff_filter_samples(link, buf);
} }
......
...@@ -278,7 +278,7 @@ static int aiff_read_header(AVFormatContext *s) ...@@ -278,7 +278,7 @@ static int aiff_read_header(AVFormatContext *s)
st->codec->block_align = AV_RB32(st->codec->extradata+11*4); st->codec->block_align = AV_RB32(st->codec->extradata+11*4);
break; break;
case MKTAG('C','H','A','N'): case MKTAG('C','H','A','N'):
if(ff_mov_read_chan(s, st, size) < 0) if(ff_mov_read_chan(s, pb, st, size) < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
break; break;
default: /* Jump */ default: /* Jump */
......
...@@ -268,7 +268,7 @@ static int read_header(AVFormatContext *s) ...@@ -268,7 +268,7 @@ static int read_header(AVFormatContext *s)
break; break;
case MKBETAG('c','h','a','n'): case MKBETAG('c','h','a','n'):
if ((ret = ff_mov_read_chan(s, st, size)) < 0) if ((ret = ff_mov_read_chan(s, s->pb, st, size)) < 0)
return ret; return ret;
break; break;
......
...@@ -197,7 +197,7 @@ int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom); ...@@ -197,7 +197,7 @@ int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags); enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries); int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries);
int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size); int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size);
void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout); void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout);
#endif /* AVFORMAT_ISOM_H */ #endif /* AVFORMAT_ISOM_H */
...@@ -676,7 +676,7 @@ static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -676,7 +676,7 @@ static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (atom.size < 16) if (atom.size < 16)
return 0; return 0;
ff_mov_read_chan(c->fc, st, atom.size - 4); ff_mov_read_chan(c->fc, pb, st, atom.size - 4);
return 0; return 0;
} }
...@@ -2575,7 +2575,7 @@ static int mov_read_chan2(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -2575,7 +2575,7 @@ static int mov_read_chan2(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (atom.size < 16) if (atom.size < 16)
return 0; return 0;
avio_skip(pb, 4); avio_skip(pb, 4);
ff_mov_read_chan(c->fc,c->fc->streams[0], atom.size - 4); ff_mov_read_chan(c->fc, pb, c->fc->streams[0], atom.size - 4);
return 0; return 0;
} }
......
...@@ -543,9 +543,9 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, ...@@ -543,9 +543,9 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
return tag; return tag;
} }
int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size) int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
int64_t size)
{ {
AVIOContext *pb = s->pb;
uint32_t layout_tag, bitmap, num_descr, label_mask; uint32_t layout_tag, bitmap, num_descr, label_mask;
int i; int i;
......
...@@ -57,10 +57,12 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id, ...@@ -57,10 +57,12 @@ uint32_t ff_mov_get_channel_layout_tag(enum AVCodecID codec_id,
* Read 'chan' tag from the input stream. * Read 'chan' tag from the input stream.
* *
* @param s AVFormatContext * @param s AVFormatContext
* @param pb AVIOContext
* @param st The stream to set codec values for * @param st The stream to set codec values for
* @param size Remaining size in the 'chan' tag * @param size Remaining size in the 'chan' tag
* @return 0 if ok, or negative AVERROR code on failure * @return 0 if ok, or negative AVERROR code on failure
*/ */
int ff_mov_read_chan(AVFormatContext *s, AVStream *st, int64_t size); int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
int64_t size);
#endif /* AVFORMAT_MOV_CHAN_H */ #endif /* AVFORMAT_MOV_CHAN_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment