From 187a537904ef2193a4b5e0312349f95223ff8610 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Sat, 9 Apr 2011 17:22:04 -0700 Subject: [PATCH 1/8] Convert some undefined 1<<31 shifts into 1U<<31. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to ISO 9899:1999 S 6.5.7/4: The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1× 2^E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1× 2^E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined. --- libavcodec/aacdec.c | 12 ++++++------ libavcodec/dsputil.c | 4 ++-- libavcodec/fraps.c | 4 ++-- libavcodec/ppc/fft_altivec.c | 2 +- libavcodec/vorbis_enc.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 3ce0dce491..c9761a1aef 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -964,19 +964,19 @@ static inline float *VMUL4S(float *dst, const float *v, unsigned idx, union float754 s = { .f = *scale }; union float754 t; - t.i = s.i ^ (sign & 1<<31); + t.i = s.i ^ (sign & 1U<<31); *dst++ = v[idx & 3] * t.f; sign <<= nz & 1; nz >>= 1; - t.i = s.i ^ (sign & 1<<31); + t.i = s.i ^ (sign & 1U<<31); *dst++ = v[idx>>2 & 3] * t.f; sign <<= nz & 1; nz >>= 1; - t.i = s.i ^ (sign & 1<<31); + t.i = s.i ^ (sign & 1U<<31); *dst++ = v[idx>>4 & 3] * t.f; sign <<= nz & 1; nz >>= 1; - t.i = s.i ^ (sign & 1<<31); + t.i = s.i ^ (sign & 1U<<31); *dst++ = v[idx>>6 & 3] * t.f; return dst; @@ -1169,11 +1169,11 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], b += 4; n = (1 << b) + SHOW_UBITS(re, gb, b); LAST_SKIP_BITS(re, gb, b); - *icf++ = cbrt_tab[n] | (bits & 1<<31); + *icf++ = cbrt_tab[n] | (bits & 1U<<31); bits <<= 1; } else { unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; - *icf++ = (bits & 1<<31) | v; + *icf++ = (bits & 1U<<31) | v; bits <<= !!v; } cb_idx >>= 4; diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 33fc78a1ea..ddaf0205de 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3827,7 +3827,7 @@ static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini, { if(a > mini) return mini; - else if((a^(1<<31)) > maxisign) return maxi; + else if((a^(1U<<31)) > maxisign) return maxi; else return a; } @@ -3835,7 +3835,7 @@ static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *mi int i; uint32_t mini = *(uint32_t*)min; uint32_t maxi = *(uint32_t*)max; - uint32_t maxisign = maxi ^ (1<<31); + uint32_t maxisign = maxi ^ (1U<<31); uint32_t *dsti = (uint32_t*)dst; const uint32_t *srci = (const uint32_t*)src; for(i=0; ipict_type = (header & (1<<31))? FF_P_TYPE : FF_I_TYPE; + f->pict_type = (header & (1U<<31))? FF_P_TYPE : FF_I_TYPE; f->key_frame = f->pict_type == FF_I_TYPE; if (f->pict_type == FF_I_TYPE) { @@ -223,7 +223,7 @@ static int decode_frame(AVCodecContext *avctx, return -1; } /* bit 31 means same as previous pic */ - f->pict_type = (header & (1<<31))? FF_P_TYPE : FF_I_TYPE; + f->pict_type = (header & (1U<<31))? FF_P_TYPE : FF_I_TYPE; f->key_frame = f->pict_type == FF_I_TYPE; if (f->pict_type == FF_I_TYPE) { diff --git a/libavcodec/ppc/fft_altivec.c b/libavcodec/ppc/fft_altivec.c index 68f3071f35..435024a0cb 100644 --- a/libavcodec/ppc/fft_altivec.c +++ b/libavcodec/ppc/fft_altivec.c @@ -122,7 +122,7 @@ static void ff_imdct_calc_altivec(FFTContext *s, FFTSample *output, const FFTSam int n = 1 << s->mdct_bits; int n4 = n >> 2; int n16 = n >> 4; - vec_u32 sign = {1<<31,1<<31,1<<31,1<<31}; + vec_u32 sign = {1U<<31,1U<<31,1U<<31,1U<<31}; vec_u32 *p0 = (vec_u32*)(output+n4); vec_u32 *p1 = (vec_u32*)(output+n4*3); diff --git a/libavcodec/vorbis_enc.c b/libavcodec/vorbis_enc.c index 7c5d521464..748fbd66fe 100644 --- a/libavcodec/vorbis_enc.c +++ b/libavcodec/vorbis_enc.c @@ -394,7 +394,7 @@ static void put_float(PutBitContext *pb, float f) mant = (int)ldexp(frexp(f, &exp), 20); exp += 788 - 20; if (mant < 0) { - res |= (1 << 31); + res |= (1U << 31); mant = -mant; } res |= mant | (exp << 21); From 2f072b55a49eb56b1bcffdda344f21d09981430b Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Sun, 10 Apr 2011 23:42:29 -0700 Subject: [PATCH 2/8] Fix the conversion of AV_SAMPLE_FMT_FLT and _DBL to AV_SAMPLE_FMT_S32. (1<<31) is undefined and seems to be evaluated by gcc to -2^31 when these formulae require 2^31. These conversions still need fate tests. --- libavcodec/audioconvert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c index c5977b6efb..4bea30848f 100644 --- a/libavcodec/audioconvert.c +++ b/libavcodec/audioconvert.c @@ -145,8 +145,8 @@ if(ctx->fmt_pair == ofmt + AV_SAMPLE_FMT_NB*ifmt){\ else CONV(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S32, (*(const int32_t*)pi>>24) + 0x80) else CONV(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S32, *(const int32_t*)pi>>16) else CONV(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S32, *(const int32_t*)pi) - else CONV(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31))) - else CONV(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1<<31))) + else CONV(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1U<<31))) + else CONV(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_S32, *(const int32_t*)pi*(1.0 / (1U<<31))) else CONV(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8( lrintf(*(const float*)pi * (1<<7)) + 0x80)) else CONV(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16( lrintf(*(const float*)pi * (1<<15)))) else CONV(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float*)pi * (1U<<31)))) From c41eb2ade4f862dc5f5e7c09c717d4f7f911a15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 12 Apr 2011 10:32:43 +0300 Subject: [PATCH 3/8] libavcodec: Use "const enum AVSampleFormat[]" in AVCodec initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/amrnbdec.c | 2 +- libavcodec/amrwbdec.c | 2 +- libavcodec/g722.c | 2 +- libavcodec/libvo-aacenc.c | 2 +- libavcodec/libvo-amrwbenc.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index f21b738685..4e24e26d68 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -1044,5 +1044,5 @@ AVCodec ff_amrnb_decoder = { .init = amrnb_decode_init, .decode = amrnb_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate NarrowBand"), - .sample_fmts = (enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, }; diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 00df227b5e..d4bb7760ef 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -1233,5 +1233,5 @@ AVCodec ff_amrwb_decoder = { .init = amrwb_decode_init, .decode = amrwb_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("Adaptive Multi-Rate WideBand"), - .sample_fmts = (enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, }; diff --git a/libavcodec/g722.c b/libavcodec/g722.c index 422a1343ba..257292de7f 100644 --- a/libavcodec/g722.c +++ b/libavcodec/g722.c @@ -577,7 +577,7 @@ AVCodec ff_adpcm_g722_encoder = { .close = g722_close, .encode = g722_encode_frame, .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), - .sample_fmts = (enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, }; #endif diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index 65c2745695..eb340580a5 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -122,7 +122,7 @@ AVCodec ff_libvo_aacenc_encoder = { aac_encode_frame, aac_encode_close, NULL, - .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libvo-aacenc AAC"), }; diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index 6f26d9b8af..45da104f94 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -120,7 +120,7 @@ AVCodec ff_libvo_amrwbenc_encoder = { amr_wb_encode_frame, amr_wb_encode_close, NULL, - .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libvo-amrwbenc Adaptive Multi-Rate " "(AMR) Wide-Band"), }; From b5304f7b2ec56b872e9a007d7f040930ebe55095 Mon Sep 17 00:00:00 2001 From: Kharkov Alexander Date: Fri, 8 Apr 2011 16:20:45 +0700 Subject: [PATCH 4/8] flvdec: Fix support for flvtool2 "keyframes based" generated index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current keyframes data parser unconditionally rewind metadata to the end at the end of function. As result ALL metadata located after keyframes index not parsed, and as metadata object can have ANY placement inside metadata it can lead to unpredictable result (bitrate can not be found, etc.). As result FLV movie will not play at all in such situation. Signed-off-by: Martin Storsjö --- libavformat/flvdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index f27b70c0c6..62d25c8802 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -136,6 +136,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream int64_t *times = NULL; int64_t *filepositions = NULL; int ret = 0; + int64_t initial_pos = avio_tell(ioc); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { int64_t* current_array; @@ -183,7 +184,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream finish: av_freep(×); av_freep(&filepositions); - avio_seek(ioc, max_pos, SEEK_SET); + avio_seek(ioc, initial_pos, SEEK_SET); return ret; } From c5e03cebd31e5bd2b6851d09a60280403a57faf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 12 Apr 2011 10:33:35 +0300 Subject: [PATCH 5/8] libvo-*: Don't use deprecated sample format names and enum names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/libvo-aacenc.c | 2 +- libavcodec/libvo-amrwbenc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index eb340580a5..205c00e922 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -122,7 +122,7 @@ AVCodec ff_libvo_aacenc_encoder = { aac_encode_frame, aac_encode_close, NULL, - .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libvo-aacenc AAC"), }; diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index 45da104f94..661a15d445 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -120,7 +120,7 @@ AVCodec ff_libvo_amrwbenc_encoder = { amr_wb_encode_frame, amr_wb_encode_close, NULL, - .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("libvo-amrwbenc Adaptive Multi-Rate " "(AMR) Wide-Band"), }; From ff1ec0c3f8fce10e92010f82f7e859e08f9c742a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Apr 2011 09:37:10 +0200 Subject: [PATCH 6/8] avio: undeprecate av_url_read_fseek/fpause under nicer names It seems their replacements won't be ready anytime soon. --- libavformat/asfdec.c | 2 +- libavformat/avio.h | 27 +++++++++++++++++++++++++++ libavformat/avio_internal.h | 26 -------------------------- libavformat/aviobuf.c | 8 ++++---- libavformat/flvdec.c | 4 ++-- libavformat/utils.c | 4 ++-- 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 20b498758e..57e8fb6df4 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1242,7 +1242,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int /* Try using the protocol's read_seek if available */ if(s->pb) { - int ret = ffio_read_seek(s->pb, stream_index, pts, flags); + int ret = avio_seek_time(s->pb, stream_index, pts, flags); if(ret >= 0) asf_reset_header(s); if (ret != AVERROR(ENOSYS)) diff --git a/libavformat/avio.h b/libavformat/avio.h index 7e7e429117..b980d491ae 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -617,4 +617,31 @@ int udp_get_file_handle(URLContext *h); */ const char *avio_enum_protocols(void **opaque, int output); +/** + * Pause and resume playing - only meaningful if using a network streaming + * protocol (e.g. MMS). + * @param pause 1 for pause, 0 for resume + */ +int avio_pause(AVIOContext *h, int pause); + +/** + * Seek to a given timestamp relative to some component stream. + * Only meaningful if using a network streaming protocol (e.g. MMS.). + * @param stream_index The stream index that the timestamp is relative to. + * If stream_index is (-1) the timestamp should be in AV_TIME_BASE + * units from the beginning of the presentation. + * If a stream_index >= 0 is used and the protocol does not support + * seeking based on component streams, the call will fail with ENOTSUP. + * @param timestamp timestamp in AVStream.time_base units + * or if there is no stream specified then in AV_TIME_BASE units. + * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE + * and AVSEEK_FLAG_ANY. The protocol may silently ignore + * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will + * fail with ENOTSUP if used and not supported. + * @return >= 0 on success + * @see AVInputFormat::read_seek + */ +int64_t avio_seek_time(AVIOContext *h, int stream_index, + int64_t timestamp, int flags); + #endif /* AVFORMAT_AVIO_H */ diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 721a3c4602..6630aaf61d 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -67,32 +67,6 @@ uint64_t ffio_read_varlen(AVIOContext *bc); /** @warning must be called before any I/O */ int ffio_set_buf_size(AVIOContext *s, int buf_size); -/** - * Pause and resume playing - only meaningful if using a network streaming - * protocol (e.g. MMS). - * @param pause 1 for pause, 0 for resume - */ -int ffio_read_pause(AVIOContext *h, int pause); -/** - * Seek to a given timestamp relative to some component stream. - * Only meaningful if using a network streaming protocol (e.g. MMS.). - * @param stream_index The stream index that the timestamp is relative to. - * If stream_index is (-1) the timestamp should be in AV_TIME_BASE - * units from the beginning of the presentation. - * If a stream_index >= 0 is used and the protocol does not support - * seeking based on component streams, the call will fail with ENOTSUP. - * @param timestamp timestamp in AVStream.time_base units - * or if there is no stream specified then in AV_TIME_BASE units. - * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE - * and AVSEEK_FLAG_ANY. The protocol may silently ignore - * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will - * fail with ENOTSUP if used and not supported. - * @return >= 0 on success - * @see AVInputFormat::read_seek - */ -int64_t ffio_read_seek (AVIOContext *h, int stream_index, - int64_t timestamp, int flags); - void ffio_init_checksum(AVIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum); diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 3814db6dfc..cde5f269b5 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -403,12 +403,12 @@ void put_flush_packet(AVIOContext *s) } int av_url_read_fpause(AVIOContext *s, int pause) { - return ffio_read_pause(s, pause); + return avio_pause(s, pause); } int64_t av_url_read_fseek(AVIOContext *s, int stream_index, int64_t timestamp, int flags) { - return ffio_read_seek(s, stream_index, timestamp, flags); + return avio_seek_time(s, stream_index, timestamp, flags); } void init_checksum(AVIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), @@ -1013,14 +1013,14 @@ int url_fget_max_packet_size(AVIOContext *s) } #endif -int ffio_read_pause(AVIOContext *s, int pause) +int avio_pause(AVIOContext *s, int pause) { if (!s->read_pause) return AVERROR(ENOSYS); return s->read_pause(s->opaque, pause); } -int64_t ffio_read_seek(AVIOContext *s, int stream_index, +int64_t avio_seek_time(AVIOContext *s, int stream_index, int64_t timestamp, int flags) { URLContext *h = s->opaque; diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 62d25c8802..94159be3c4 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -529,7 +529,7 @@ leave: static int flv_read_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags) { - return ffio_read_seek(s->pb, stream_index, ts, flags); + return avio_seek_time(s->pb, stream_index, ts, flags); } #if 0 /* don't know enough to implement this */ @@ -550,7 +550,7 @@ static int flv_read_seek2(AVFormatContext *s, int stream_index, ts = av_rescale_rnd(ts, 1000, AV_TIME_BASE, flags & AVSEEK_FLAG_BACKWARD ? AV_ROUND_DOWN : AV_ROUND_UP); } - ret = ffio_read_seek(s->pb, stream_index, ts, flags); + ret = avio_seek_time(s->pb, stream_index, ts, flags); } if (ret == AVERROR(ENOSYS)) diff --git a/libavformat/utils.c b/libavformat/utils.c index 1d58682a66..f93b83f5da 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2579,7 +2579,7 @@ int av_read_play(AVFormatContext *s) if (s->iformat->read_play) return s->iformat->read_play(s); if (s->pb) - return ffio_read_pause(s->pb, 0); + return avio_pause(s->pb, 0); return AVERROR(ENOSYS); } @@ -2588,7 +2588,7 @@ int av_read_pause(AVFormatContext *s) if (s->iformat->read_pause) return s->iformat->read_pause(s); if (s->pb) - return ffio_read_pause(s->pb, 1); + return avio_pause(s->pb, 1); return AVERROR(ENOSYS); } From f3e3f28e802a108120a1244744ddc1689d26be7a Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 4 Apr 2011 15:24:19 +0200 Subject: [PATCH 7/8] Error out if vaapi is not found Make the behaviour consistent with the other external deps. Signed-off-by: Anton Khirnov --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index c632ce55f1..32c3544fb3 100755 --- a/configure +++ b/configure @@ -2840,7 +2840,7 @@ for thread in $THREADS_LIST; do done check_lib math.h sin -lm -disabled vaapi || check_lib va/va.h vaInitialize -lva +enabled vaapi && require vaapi va/va.h vaInitialize -lva check_mathfunc exp2 check_mathfunc exp2f From 578d6861a753eb0b9d277f7ec17d1502eb2bb35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 12 Apr 2011 16:37:54 +0300 Subject: [PATCH 8/8] flvdec: Allow parsing keyframes metadata without seeking in most cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stop the avio input at a point where amf_parse_object can continue parsing the end of the object seamlessly, when all data is available. If unsupported data is encountered within the keyframes object, try seeking to the start of the keyframes object - if the seek back was successful, the caller can continue parsing the rest of the AMF data. Signed-off-by: Martin Storsjö --- libavformat/flvdec.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 94159be3c4..e7ec0b107f 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -135,7 +135,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream char str_val[256]; int64_t *times = NULL; int64_t *filepositions = NULL; - int ret = 0; + int ret = AVERROR(ENOSYS); int64_t initial_pos = avio_tell(ioc); while (avio_tell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { @@ -173,6 +173,12 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream num_val = av_int2dbl(avio_rb64(ioc)); current_array[i] = num_val; } + if (times && filepositions) { + // All done, exiting at a position allowing amf_parse_object + // to finish parsing the object + ret = 0; + break; + } } if (timeslen == fileposlen) @@ -184,7 +190,10 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream finish: av_freep(×); av_freep(&filepositions); - avio_seek(ioc, initial_pos, SEEK_SET); + // If we got unexpected data, but successfully reset back to + // the start pos, the caller can continue parsing + if (ret < 0 && avio_seek(ioc, initial_pos, SEEK_SET) > 0) + return 0; return ret; }