diff --git a/Doxyfile b/Doxyfile index b91f351800..7a281f27f3 100644 --- a/Doxyfile +++ b/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = 1.0.10 # With the PROJECT_LOGO tag one can specify an logo or icon that is included # in the documentation. The maximum height of the logo should not exceed 55 diff --git a/MAINTAINERS b/MAINTAINERS index b361543c0c..4992c200a5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14,7 +14,6 @@ and related discussions. Project Leader ============== -Michael Niedermayer final design decisions @@ -408,10 +407,11 @@ x86 Michael Niedermayer Releases ======== +1.2 Michael Niedermayer +1.1 Michael Niedermayer 1.0 Michael Niedermayer -0.11 Michael Niedermayer -0.10 Michael Niedermayer +If you want to maintain an older release, please contact us GnuPG Fingerprints of maintainers and contributors diff --git a/RELEASE b/RELEASE index 4402ec2c05..7ee7020b38 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -1.0.git +1.0.10 diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..7ee7020b38 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.10 diff --git a/cmdutils.c b/cmdutils.c index 5639751e3a..27e01307d2 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -61,7 +61,7 @@ struct SwsContext *sws_opts; SwrContext *swr_opts; AVDictionary *format_opts, *codec_opts; -const int this_year = 2012; +const int this_year = 2014; static FILE *report_file; diff --git a/cmdutils.h b/cmdutils.h index d78eb55b44..ed808ed83a 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -190,13 +190,13 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, void show_help_children(const AVClass *class, int flags); /** - * Per-avtool specific help handler. Implemented in each - * avtool, called by show_help(). + * Per-fftool specific help handler. Implemented in each + * fftool, called by show_help(). */ void show_help_default(const char *opt, const char *arg); /** - * Generic -h handler common to all avtools. + * Generic -h handler common to all fftools. */ int show_help(void *optctx, const char *opt, const char *arg); diff --git a/configure b/configure index d2d3a66574..da22efd2b9 100755 --- a/configure +++ b/configure @@ -1921,6 +1921,9 @@ showspectrum_filter_deps="avcodec" super2xsai_filter_deps="gpl" tinterlace_filter_deps="gpl" yadif_filter_deps="gpl" +pixfmts_super2xsai_test_deps="super2xsai_filter" +tinterlace_merge_test_deps="tinterlace_filter" +tinterlace_pad_test_deps="tinterlace_filter" # libraries avdevice_deps="avcodec avformat" @@ -1947,18 +1950,16 @@ doc_deps_any="manpages htmlpages podpages txtpages" # tests colormatrix1_test_deps="colormatrix_filter" colormatrix2_test_deps="colormatrix_filter" -flashsv2_test_deps="zlib" mpg_test_deps="mpeg1system_muxer mpegps_demuxer" -mpng_test_deps="zlib" +png_test_deps="zlib" pp_test_deps="mp_filter" pp2_test_deps="mp_filter" pp3_test_deps="mp_filter" pp4_test_deps="mp_filter" pp5_test_deps="mp_filter" pp6_test_deps="mp_filter" +seek_flashsv_flv_test_deps="zlib" seek_lavf_mxf_d10_test_deps="mxf_d10_test" -zlib_test_deps="zlib" -zmbv_test_deps="zlib" test_deps(){ suf1=$1 @@ -2494,7 +2495,9 @@ probe_cc(){ unset _depflags _DEPCMD _DEPFLAGS _flags_filter=echo - if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then + if $_cc --version 2>&1 | grep -q '^GNU assembler'; then + true # no-op to avoid reading stdin in following checks + elif $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then _type=llvm_gcc gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)') _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver" @@ -3636,7 +3639,7 @@ enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_in enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 enabled libaacplus && require "libaacplus >= 2.0.0" aacplus.h aacplusEncOpen -laacplus enabled libass && require_pkg_config libass ass/ass.h ass_library_init -enabled libbluray && require libbluray libbluray/bluray.h bd_open -lbluray +enabled libbluray && require_pkg_config libbluray libbluray/bluray.h bd_open enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && { check_lib celt/celt.h celt_decoder_create_custom -lcelt0 || die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } @@ -3731,7 +3734,7 @@ pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man check_header linux/fb.h check_header linux/videodev.h check_header linux/videodev2.h -check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete +check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete check_header sys/videoio.h @@ -3892,11 +3895,13 @@ elif enabled gcc; then check_cflags -fno-tree-vectorize check_cflags -Werror=implicit-function-declaration check_cflags -Werror=missing-prototypes + check_cflags -Werror=return-type elif enabled llvm_gcc; then check_cflags -mllvm -stack-alignment=16 elif enabled clang; then check_cflags -mllvm -stack-alignment=16 check_cflags -Qunused-arguments + check_cflags -Werror=return-type elif enabled armcc; then # 2523: use of inline assembler is deprecated add_cflags -W${armcc_opt},--diag_suppress=2523 diff --git a/doc/APIchanges b/doc/APIchanges index 6584e1950f..092d1b6706 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -102,90 +102,90 @@ API changes, most recent first: Add codec descriptors for accessing codec properties without having to refer to a specific decoder or encoder. - c223d79 - Add an AVCodecDescriptor struct and functions + f5f3684 / c223d79 - Add an AVCodecDescriptor struct and functions avcodec_descriptor_get() and avcodec_descriptor_next(). - 51efed1 - Add AVCodecDescriptor.props and AV_CODEC_PROP_INTRA_ONLY. - 91e59fe - Add avcodec_descriptor_get_by_name(). + f5f3684 / 51efed1 - Add AVCodecDescriptor.props and AV_CODEC_PROP_INTRA_ONLY. + 6c180b3 / 91e59fe - Add avcodec_descriptor_get_by_name(). -2012-08-08 - 987170c - lavu 51.38 - dict.h +2012-08-08 - f5f3684 / 987170c - lavu 51.68.100 / 51.38.0 - dict.h Add av_dict_count(). -2012-08-07 - 104e10f - lavc 54.25 - avcodec.h +2012-08-07 - 7a72695 / 104e10f - lavc 54.51.100 / 54.25.0 - avcodec.h Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*. To provide backwards compatibility, CodecID is now #defined as AVCodecID. Note that this can break user code that includes avcodec.h and uses the 'CodecID' identifier. Such code should either #undef CodecID or stop using the CodecID name. -2012-08-03 - 239fdf1 - lavu 51.37.1 - cpu.h +2012-08-03 - e776ee8 / 239fdf1 - lavu 51.66.101 / 51.37.1 - cpu.h lsws 2.1.1 - swscale.h Rename AV_CPU_FLAG_MMX2 ---> AV_CPU_FLAG_MMXEXT. Rename SWS_CPU_CAPS_MMX2 ---> SWS_CPU_CAPS_MMXEXT. -2012-07-29 - 681ed00 - lavf 54.13.0 - avformat.h +2012-07-29 - 7c26761 / 681ed00 - lavf 54.22.100 / 54.13.0 - avformat.h Add AVFMT_FLAG_NOBUFFER for low latency use cases. 2012-07-10 - 5fade8a - lavu 51.37.0 Add av_malloc_array() and av_mallocz_array() -2012-06-22 - d3d3a32 - lavu 51.34.0 +2012-06-22 - e847f41 / d3d3a32 - lavu 51.61.100 / 51.34.0 Add av_usleep() -2012-06-20 - ae0a301 - lavu 51.33.0 +2012-06-20 - 4da42eb / ae0a301 - lavu 51.60.100 / 51.33.0 Move av_gettime() to libavutil, add libavutil/time.h -2012-06-09 - 3971be0 - lavr 0.0.3 +2012-06-09 - 82edf67 / 3971be0 - lavr 0.0.3 Add a parameter to avresample_build_matrix() for Dolby/DPLII downmixing. -2012-06-12 - 9baeff9 - lavfi 2.23.0 - avfilter.h +2012-06-12 - c7b9eab / 9baeff9 - lavfi 2.79.100 / 2.23.0 - avfilter.h Add AVFilterContext.nb_inputs/outputs. Deprecate AVFilterContext.input/output_count. -2012-06-12 - 84b9fbe - lavfi 2.22.0 - avfilter.h +2012-06-12 - c7b9eab / 84b9fbe - lavfi 2.79.100 / 2.22.0 - avfilter.h Add avfilter_pad_get_type() and avfilter_pad_get_name(). Those should now be used instead of accessing AVFilterPad members directly. -2012-06-12 - b0f0dfc - lavu 51.32.0 - audioconvert.h +2012-06-12 - 3630a07 / b0f0dfc - lavu 51.57.100 / 51.32.0 - audioconvert.h Add av_get_channel_layout_channel_index(), av_get_channel_name() and av_channel_layout_extract_channel(). -2012-05-25 - 154486f - lavu 51.31.0 - opt.h +2012-05-25 - 53ce990 / 154486f - lavu 51.55.100 / 51.31.0 - opt.h Add av_opt_set_bin() -2012-05-15 - lavfi 2.17.0 +2012-05-15 - lavfi 2.74.100 / 2.17.0 Add support for audio filters - ac71230/a2cd9be - add video/audio buffer sink in a new installed + 61930bd / ac71230, 1cbf7fb / a2cd9be - add video/audio buffer sink in a new installed header buffersink.h - 720c6b7 - add av_buffersrc_write_frame(), deprecate + 1cbf7fb / 720c6b7 - add av_buffersrc_write_frame(), deprecate av_vsrc_buffer_add_frame() - ab16504 - add avfilter_copy_buf_props() - 9453c9e - add extended_data to AVFilterBuffer - 1b8c927 - add avfilter_get_audio_buffer_ref_from_arrays() + 61930bd / ab16504 - add avfilter_copy_buf_props() + 61930bd / 9453c9e - add extended_data to AVFilterBuffer + 61930bd / 1b8c927 - add avfilter_get_audio_buffer_ref_from_arrays() -2012-05-09 - lavu 51.30.0 - samplefmt.h - 142e740 - add av_samples_copy() - 6d7f617 - add av_samples_set_silence() +2012-05-09 - lavu 51.53.100 / 51.30.0 - samplefmt.h + 61930bd / 142e740 - add av_samples_copy() + 61930bd / 6d7f617 - add av_samples_set_silence() -2012-05-09 - a5117a2 - lavc 54.13.1 +2012-05-09 - 61930bd / a5117a2 - lavc 54.21.101 / 54.13.1 For audio formats with fixed frame size, the last frame no longer needs to be padded with silence, libavcodec will handle this internally (effectively all encoders behave as if they had CODEC_CAP_SMALL_LAST_FRAME set). -2012-05-07 - 828bd08 - lavc 54.13.0 - avcodec.h +2012-05-07 - 653d117 / 828bd08 - lavc 54.20.100 / 54.13.0 - avcodec.h Add sample_rate and channel_layout fields to AVFrame. -2012-05-01 - 4010d72 - lavr 0.0.1 +2012-05-01 - 2330eb1 / 4010d72 - lavr 0.0.1 Change AV_MIX_COEFF_TYPE_Q6 to AV_MIX_COEFF_TYPE_Q8. -2012-04-25 - 3527a73 - lavu 51.29.0 - cpu.h +2012-04-25 - e890b68 / 3527a73 - lavu 51.48.100 / 51.29.0 - cpu.h Add av_parse_cpu_flags() -2012-04-24 - c8af852 - lavr 0.0.0 +2012-04-24 - 3ead79e / c8af852 - lavr 0.0.0 Add libavresample audio conversion library -2012-04-20 - 0c0d1bc - lavu 51.28.0 - audio_fifo.h +2012-04-20 - 3194ab7 / 0c0d1bc - lavu 51.47.100 / 51.28.0 - audio_fifo.h Add audio FIFO functions: av_audio_fifo_free() av_audio_fifo_alloc() @@ -197,10 +197,10 @@ API changes, most recent first: av_audio_fifo_size() av_audio_fifo_space() -2012-04-14 - lavfi 2.16.0 - avfiltergraph.h - d7bcc71 Add avfilter_graph_parse2(). +2012-04-14 - lavfi 2.70.100 / 2.16.0 - avfiltergraph.h + 7432bcf / d7bcc71 Add avfilter_graph_parse2(). -2012-04-08 - 4d693b0 - lavu 51.27.0 - samplefmt.h +2012-04-08 - 6bfb304 / 4d693b0 - lavu 51.46.100 / 51.27.0 - samplefmt.h Add av_get_packed_sample_fmt() and av_get_planar_sample_fmt() 2012-03-21 - b75c67d - lavu 51.43.100 @@ -228,69 +228,69 @@ API changes, most recent first: 2012-01-24 - 0c3577b - lavfi 2.60.100 Add avfilter_graph_dump. -2012-03-05 - lavc 54.8.0 - 6699d07 Add av_get_exact_bits_per_sample() - 9524cf7 Add av_get_audio_frame_duration() +2012-03-05 - lavc 54.10.100 / 54.8.0 + f095391 / 6699d07 Add av_get_exact_bits_per_sample() + f095391 / 9524cf7 Add av_get_audio_frame_duration() -2012-03-04 - 44fe77b - lavc 54.7.0 - avcodec.h +2012-03-04 - 2af8f2c / 44fe77b - lavc 54.8.100 / 54.7.0 - avcodec.h Add av_codec_is_encoder/decoder(). -2012-03-01 - 442c132 - lavc 54.3.0 - avcodec.h +2012-03-01 - 1eb7f39 / 442c132 - lavc 54.5.100 / 54.3.0 - avcodec.h Add av_packet_shrink_side_data. -2012-02-29 - dd2a4bc - lavf 54.2.0 - avformat.h +2012-02-29 - 79ae084 / dd2a4bc - lavf 54.2.100 / 54.2.0 - avformat.h Add AVStream.attached_pic and AV_DISPOSITION_ATTACHED_PIC, used for dealing with attached pictures/cover art. -2012-02-25 - c9bca80 - lavu 51.24.0 - error.h +2012-02-25 - 305e4b3 / c9bca80 - lavu 51.41.100 / 51.24.0 - error.h Add AVERROR_UNKNOWN NOTE: this was backported to 0.8 -2012-02-20 - e9cda85 - lavc 54.2.0 +2012-02-20 - eadd426 / e9cda85 - lavc 54.2.100 / 54.2.0 Add duration field to AVCodecParserContext -2012-02-20 - 0b42a93 - lavu 51.23.1 - mathematics.h +2012-02-20 - eadd426 / 0b42a93 - lavu 51.40.100 / 51.23.1 - mathematics.h Add av_rescale_q_rnd() -2012-02-08 - 38d5533 - lavu 51.22.1 - pixdesc.h +2012-02-08 - f2b20b7 / 38d5533 - lavu 51.38.101 / 51.22.1 - pixdesc.h Add PIX_FMT_PSEUDOPAL flag. -2012-02-08 - 52f82a1 - lavc 54.01.0 +2012-02-08 - f2b20b7 / 52f82a1 - lavc 54.2.100 / 54.1.0 Add avcodec_encode_video2() and deprecate avcodec_encode_video(). -2012-02-01 - 316fc74 - lavc 54.01.0 +2012-02-01 - 4c677df / 316fc74 - lavc 54.1.0 Add av_fast_padded_malloc() as alternative for av_realloc() when aligned memory is required. The buffer will always have FF_INPUT_BUFFER_PADDING_SIZE zero-padded bytes at the end. -2012-01-31 - dd6d3b0 - lavf 54.01.0 +2012-01-31 - a369a6b / dd6d3b0 - lavf 54.1.0 Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags(). NOTE: this was backported to 0.8 -2012-01-31 - af08d9a - lavc 54.01.0 +2012-01-31 - a369a6b / af08d9a - lavc 54.1.0 Add avcodec_is_open() function. NOTE: this was backported to 0.8 -2012-01-30 - 8b93312 - lavu 51.22.0 - intfloat.h +2012-01-30 - 151ecc2 / 8b93312 - lavu 51.36.100 / 51.22.0 - intfloat.h Add a new installed header libavutil/intfloat.h with int/float punning functions. NOTE: this was backported to 0.8 -2012-01-25 - lavf 53.22.0 - f1caf01 Allow doing av_write_frame(ctx, NULL) for flushing possible +2012-01-25 - lavf 53.31.100 / 53.22.0 + 3c5fe5b / f1caf01 Allow doing av_write_frame(ctx, NULL) for flushing possible buffered data within a muxer. Added AVFMT_ALLOW_FLUSH for muxers supporting it (av_write_frame makes sure it is called only for muxers with this flag). -2012-01-15 - lavc 53.34.0 +2012-01-15 - lavc 53.56.105 / 53.34.0 New audio encoding API: - b2c75b6 Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio + 67f5650 / b2c75b6 Add CODEC_CAP_VARIABLE_FRAME_SIZE capability for use by audio encoders. - 5ee5fa0 Add avcodec_fill_audio_frame() as a convenience function. - b2c75b6 Add avcodec_encode_audio2() and deprecate avcodec_encode_audio(). + 67f5650 / 5ee5fa0 Add avcodec_fill_audio_frame() as a convenience function. + 67f5650 / b2c75b6 Add avcodec_encode_audio2() and deprecate avcodec_encode_audio(). Add AVCodec.encode2(). -2012-01-12 - 3167dc9 - lavfi 2.15.0 +2012-01-12 - b18e17e / 3167dc9 - lavfi 2.59.100 / 2.15.0 Add a new installed header -- libavfilter/version.h -- with version macros. 2011-12-08 - a502939 - lavfi 2.52.0 @@ -311,37 +311,37 @@ API changes, most recent first: 2011-10-20 - b35e9e1 - lavu 51.22.0 Add av_strtok() to avstring.h. -2011-01-03 - b73ec05 - lavu 51.21.0 +2012-01-03 - ad1c8dd / b73ec05 - lavu 51.34.100 / 51.21.0 Add av_popcount64 -2011-12-18 - 8400b12 - lavc 53.28.1 +2011-12-18 - 7c29313 / 8400b12 - lavc 53.46.1 / 53.28.1 Deprecate AVFrame.age. The field is unused. -2011-12-12 - 5266045 - lavf 53.17.0 +2011-12-12 - 8bc7fe4 / 5266045 - lavf 53.25.0 / 53.17.0 Add avformat_close_input(). Deprecate av_close_input_file() and av_close_input_stream(). -2011-12-02 - 0eea212 - lavc 53.25.0 +2011-12-02 - e4de716 / 0eea212 - lavc 53.40.0 / 53.25.0 Add nb_samples and extended_data fields to AVFrame. Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE. Deprecate avcodec_decode_audio3() in favor of avcodec_decode_audio4(). avcodec_decode_audio4() writes output samples to an AVFrame, which allows audio decoders to use get_buffer(). -2011-12-04 - 560f773 - lavc 53.24.0 +2011-12-04 - e4de716 / 560f773 - lavc 53.40.0 / 53.24.0 Change AVFrame.data[4]/base[4]/linesize[4]/error[4] to [8] at next major bump. Change AVPicture.data[4]/linesize[4] to [8] at next major bump. Change AVCodecContext.error[4] to [8] at next major bump. Add AV_NUM_DATA_POINTERS to simplify the bump transition. -2011-11-23 - bbb46f3 - lavu 51.18.0 +2011-11-23 - 8e576d5 / bbb46f3 - lavu 51.27.0 / 51.18.0 Add av_samples_get_buffer_size(), av_samples_fill_arrays(), and av_samples_alloc(), to samplefmt.h. -2011-11-23 - 8889cc4 - lavu 51.17.0 +2011-11-23 - 8e576d5 / 8889cc4 - lavu 51.27.0 / 51.17.0 Add planar sample formats and av_sample_fmt_is_planar() to samplefmt.h. -2011-11-19 - f3a29b7 - lavc 53.21.0 +2011-11-19 - dbb38bc / f3a29b7 - lavc 53.36.0 / 53.21.0 Move some AVCodecContext fields to a new private struct, AVCodecInternal, which is accessed from a new field, AVCodecContext.internal. - fields moved: @@ -349,55 +349,55 @@ API changes, most recent first: AVCodecContext.internal_buffer_count --> AVCodecInternal.buffer_count AVCodecContext.is_copy --> AVCodecInternal.is_copy -2011-11-16 - 6270671 - lavu 51.16.0 +2011-11-16 - 8709ba9 / 6270671 - lavu 51.26.0 / 51.16.0 Add av_timegm() -2011-11-13 - lavf 53.15.0 +2011-11-13 - lavf 53.21.0 / 53.15.0 New interrupt callback API, allowing per-AVFormatContext/AVIOContext interrupt callbacks. - 6aa0b98 Add AVIOInterruptCB struct and the interrupt_callback field to + 5f268ca / 6aa0b98 Add AVIOInterruptCB struct and the interrupt_callback field to AVFormatContext. - 1dee0ac Add avio_open2() with additional parameters. Those are + 5f268ca / 1dee0ac Add avio_open2() with additional parameters. Those are an interrupt callback and an options AVDictionary. This will allow passing AVOptions to protocols after lavf 54.0. -2011-11-06 - ba04ecf - lavu 51.14.0 +2011-11-06 - 13b7781 / ba04ecf - lavu 51.24.0 / 51.14.0 Add av_strcasecmp() and av_strncasecmp() to avstring.h. -2011-11-06 - 07b172f - lavu 51.13.0 +2011-11-06 - 13b7781 / 07b172f - lavu 51.24.0 / 51.13.0 Add av_toupper()/av_tolower() -2011-11-05 - b6d08f4 - lavf 53.13.0 +2011-11-05 - d8cab5c / b6d08f4 - lavf 53.19.0 / 53.13.0 Add avformat_network_init()/avformat_network_deinit() -2011-10-27 - 512557b - lavc 53.15.0 +2011-10-27 - 6faf0a2 / 512557b - lavc 53.24.0 / 53.15.0 Remove avcodec_parse_frame. Deprecate AVCodecContext.parse_only and CODEC_CAP_PARSE_ONLY. -2011-10-19 - 569129a - lavf 53.10.0 +2011-10-19 - d049257 / 569129a - lavf 53.17.0 / 53.10.0 Add avformat_new_stream(). Deprecate av_new_stream(). -2011-10-13 - b631fba - lavf 53.9.0 +2011-10-13 - 91eb1b1 / b631fba - lavf 53.16.0 / 53.9.0 Add AVFMT_NO_BYTE_SEEK AVInputFormat flag. -2011-10-12 - lavu 51.12.0 +2011-10-12 - lavu 51.21.0 / 51.12.0 AVOptions API rewrite. - - 145f741 FF_OPT_TYPE* renamed to AV_OPT_TYPE_* + - f884ef0 / 145f741 FF_OPT_TYPE* renamed to AV_OPT_TYPE_* - new setting/getting functions with slightly different semantics: - dac66da av_set_string3 -> av_opt_set + f884ef0 / dac66da av_set_string3 -> av_opt_set av_set_double -> av_opt_set_double av_set_q -> av_opt_set_q av_set_int -> av_opt_set_int - 41d9d51 av_get_string -> av_opt_get + f884ef0 / 41d9d51 av_get_string -> av_opt_get av_get_double -> av_opt_get_double av_get_q -> av_opt_get_q av_get_int -> av_opt_get_int - - 8c5dcaa trivial rename av_next_option -> av_opt_next - - 641c7af new functions - av_opt_child_next, av_opt_child_class_next + - f884ef0 / 8c5dcaa trivial rename av_next_option -> av_opt_next + - f884ef0 / 641c7af new functions - av_opt_child_next, av_opt_child_class_next and av_opt_find2() 2011-09-22 - a70e787 - lavu 51.17.0 @@ -443,31 +443,31 @@ API changes, most recent first: 2011-08-20 - 69e2c1a - lavu 51.13.0 Add av_get_media_type_string(). -2011-09-03 - fb4ca26 - lavc 53.13.0 +2011-09-03 - 1889c67 / fb4ca26 - lavc 53.13.0 lavf 53.11.0 lsws 2.1.0 Add {avcodec,avformat,sws}_get_class(). -2011-08-03 - c11fb82 - lavu 51.15.0 +2011-08-03 - 1889c67 / c11fb82 - lavu 51.15.0 Add AV_OPT_SEARCH_FAKE_OBJ flag for av_opt_find() function. 2011-08-14 - 323b930 - lavu 51.12.0 Add av_fifo_peek2(), deprecate av_fifo_peek(). -2011-08-26 - lavu 51.9.0 - - add41de..abc78a5 Do not include intfloat_readwrite.h, +2011-08-26 - lavu 51.14.0 / 51.9.0 + - 976a8b2 / add41de..976a8b2 / abc78a5 Do not include intfloat_readwrite.h, mathematics.h, rational.h, pixfmt.h, or log.h from avutil.h. -2011-08-16 - 48f9e45 - lavf 53.8.0 +2011-08-16 - 27fbe31 / 48f9e45 - lavf 53.11.0 / 53.8.0 Add avformat_query_codec(). -2011-08-16 - bca06e7 - lavc 53.11.0 +2011-08-16 - 27fbe31 / bca06e7 - lavc 53.11.0 Add avcodec_get_type(). -2011-08-06 - 2f63440 - lavf 53.7.0 +2011-08-06 - 0cb233c / 2f63440 - lavf 53.7.0 Add error_recognition to AVFormatContext. -2011-08-02 - 9d39cbf - lavc 53.9.1 +2011-08-02 - 1d186e9 / 9d39cbf - lavc 53.9.1 Add AV_PKT_FLAG_CORRUPT AVPacket flag. 2011-07-16 - b57df29 - lavfi 2.27.0 @@ -478,11 +478,11 @@ API changes, most recent first: avfilter_set_common_packing_formats() avfilter_all_packing_formats() -2011-07-10 - a67c061 - lavf 53.6.0 +2011-07-10 - 3602ad7 / a67c061 - lavf 53.6.0 Add avformat_find_stream_info(), deprecate av_find_stream_info(). NOTE: this was backported to 0.7 -2011-07-10 - 0b950fe - lavc 53.8.0 +2011-07-10 - 3602ad7 / 0b950fe - lavc 53.8.0 Add avcodec_open2(), deprecate avcodec_open(). NOTE: this was backported to 0.7 @@ -525,35 +525,35 @@ API changes, most recent first: 2011-06-12 - 6119b23 - lavfi 2.16.0 - avfilter_graph_parse() Change avfilter_graph_parse() signature. -2011-06-23 - 67e9ae1 - lavu 51.8.0 - attributes.h +2011-06-23 - 686959e / 67e9ae1 - lavu 51.10.0 / 51.8.0 - attributes.h Add av_printf_format(). -2011-06-16 - 05e84c9, 25de595 - lavf 53.2.0 - avformat.h +2011-06-16 - 2905e3f / 05e84c9, 2905e3f / 25de595 - lavf 53.4.0 / 53.2.0 - avformat.h Add avformat_open_input and avformat_write_header(). Deprecate av_open_input_stream, av_open_input_file, AVFormatParameters and av_write_header. -2011-06-16 - 7e83e1c, dc59ec5 - lavu 51.7.0 - opt.h +2011-06-16 - 2905e3f / 7e83e1c, 2905e3f / dc59ec5 - lavu 51.9.0 / 51.7.0 - opt.h Add av_opt_set_dict() and av_opt_find(). Deprecate av_find_opt(). Add AV_DICT_APPEND flag. -2011-06-10 - cb7c11c - lavu 51.6.0 - opt.h +2011-06-10 - 45fb647 / cb7c11c - lavu 51.6.0 - opt.h Add av_opt_flag_is_set(). 2011-06-10 - c381960 - lavfi 2.15.0 - avfilter_get_audio_buffer_ref_from_arrays Add avfilter_get_audio_buffer_ref_from_arrays() to avfilter.h. -2011-06-09 - d9f80ea - lavu 51.8.0 - AVMetadata +2011-06-09 - f9ecb84 / d9f80ea - lavu 51.8.0 - AVMetadata Move AVMetadata from lavf to lavu and rename it to AVDictionary -- new installed header dict.h. All av_metadata_* functions renamed to av_dict_*. -2011-06-07 - a6703fa - lavu 51.8.0 - av_get_bytes_per_sample() +2011-06-07 - d552f61 / a6703fa - lavu 51.8.0 - av_get_bytes_per_sample() Add av_get_bytes_per_sample() in libavutil/samplefmt.h. Deprecate av_get_bits_per_sample_fmt(). -2011-06-05 - b39b062 - lavu 51.8.0 - opt.h +2011-06-05 - f956924 / b39b062 - lavu 51.8.0 - opt.h Add av_opt_free convenience function. 2011-06-06 - 95a0242 - lavfi 2.14.0 - AVFilterBufferRefAudioProps @@ -583,7 +583,7 @@ API changes, most recent first: Add av_get_pix_fmt_name() in libavutil/pixdesc.h, and deprecate avcodec_get_pix_fmt_name() in libavcodec/avcodec.h in its favor. -2011-05-25 - 30315a8 - lavf 53.3.0 - avformat.h +2011-05-25 - 39e4206 / 30315a8 - lavf 53.3.0 - avformat.h Add fps_probe_size to AVFormatContext. 2011-05-22 - 5ecdfd0 - lavf 53.2.0 - avformat.h @@ -599,10 +599,10 @@ API changes, most recent first: 2011-05-14 - 9fdf772 - lavfi 2.6.0 - avcodec.h Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h. -2011-05-18 - 64150ff - lavc 53.7.0 - AVCodecContext.request_sample_fmt +2011-05-18 - 75a37b5 / 64150ff - lavc 53.7.0 - AVCodecContext.request_sample_fmt Add request_sample_fmt field to AVCodecContext. -2011-05-10 - 188dea1 - lavc 53.6.0 - avcodec.h +2011-05-10 - 59eb12f / 188dea1 - lavc 53.6.0 - avcodec.h Deprecate AVLPCType and the following fields in AVCodecContext: lpc_coeff_precision, prediction_order_method, min_partition_order, max_partition_order, lpc_type, lpc_passes. @@ -632,81 +632,81 @@ API changes, most recent first: Add av_dynarray_add function for adding an element to a dynamic array. -2011-04-26 - bebe72f - lavu 51.1.0 - avutil.h +2011-04-26 - d7e5aeb / bebe72f - lavu 51.1.0 - avutil.h Add AVPictureType enum and av_get_picture_type_char(), deprecate FF_*_TYPE defines and av_get_pict_type_char() defined in libavcodec/avcodec.h. -2011-04-26 - 10d3940 - lavfi 2.3.0 - avfilter.h +2011-04-26 - d7e5aeb / 10d3940 - lavfi 2.3.0 - avfilter.h Add pict_type and key_frame fields to AVFilterBufferRefVideo. -2011-04-26 - 7a11c82 - lavfi 2.2.0 - vsrc_buffer +2011-04-26 - d7e5aeb / 7a11c82 - lavfi 2.2.0 - vsrc_buffer Add sample_aspect_ratio fields to vsrc_buffer arguments -2011-04-21 - 94f7451 - lavc 53.1.0 - avcodec.h +2011-04-21 - 8772156 / 94f7451 - lavc 53.1.0 - avcodec.h Add CODEC_CAP_SLICE_THREADS for codecs supporting sliced threading. 2011-04-15 - lavc 52.120.0 - avcodec.h AVPacket structure got additional members for passing side information: - 4de339e introduce side information for AVPacket - 2d8591c make containers pass palette change in AVPacket + c407984 / 4de339e introduce side information for AVPacket + c407984 / 2d8591c make containers pass palette change in AVPacket 2011-04-12 - lavf 52.107.0 - avio.h Avio cleanup, part II - deprecate the entire URLContext API: - 175389c add avio_check as a replacement for url_exist - ff1ec0c add avio_pause and avio_seek_time as replacements + c55780d / 175389c add avio_check as a replacement for url_exist + 9891004 / ff1ec0c add avio_pause and avio_seek_time as replacements for _av_url_read_fseek/fpause - cdc6a87 deprecate av_protocol_next(), avio_enum_protocols + d4d0932 / cdc6a87 deprecate av_protocol_next(), avio_enum_protocols should be used instead. - 80c6e23 rename url_set_interrupt_cb->avio_set_interrupt_cb. - f87b1b3 rename open flags: URL_* -> AVIO_* - f8270bb add avio_enum_protocols. - 5593f03 deprecate URLProtocol. - c486dad deprecate URLContext. - 026e175 deprecate the typedef for URLInterruptCB - 8e76a19 deprecate av_register_protocol2. - b840484 deprecate URL_PROTOCOL_FLAG_NESTED_SCHEME - 1305d93 deprecate av_url_read_seek - fa104e1 deprecate av_url_read_pause - 727c7aa deprecate url_get_filename(). - 5958df3 deprecate url_max_packet_size(). - 1869ea0 deprecate url_get_file_handle(). - 32a97d4 deprecate url_filesize(). - e52a914 deprecate url_close(). - 58a48c6 deprecate url_seek(). - 925e908 deprecate url_write(). - dce3756 deprecate url_read_complete(). - bc371ac deprecate url_read(). - 0589da0 deprecate url_open(). - 62eaaea deprecate url_connect. - 5652bb9 deprecate url_alloc. - 333e894 deprecate url_open_protocol - e230705 deprecate url_poll and URLPollEntry + c88caa5 / 80c6e23 rename url_set_interrupt_cb->avio_set_interrupt_cb. + c88caa5 / f87b1b3 rename open flags: URL_* -> AVIO_* + d4d0932 / f8270bb add avio_enum_protocols. + d4d0932 / 5593f03 deprecate URLProtocol. + d4d0932 / c486dad deprecate URLContext. + d4d0932 / 026e175 deprecate the typedef for URLInterruptCB + c88caa5 / 8e76a19 deprecate av_register_protocol2. + 11d7841 / b840484 deprecate URL_PROTOCOL_FLAG_NESTED_SCHEME + 11d7841 / 1305d93 deprecate av_url_read_seek + 11d7841 / fa104e1 deprecate av_url_read_pause + 434f248 / 727c7aa deprecate url_get_filename(). + 434f248 / 5958df3 deprecate url_max_packet_size(). + 434f248 / 1869ea0 deprecate url_get_file_handle(). + 434f248 / 32a97d4 deprecate url_filesize(). + 434f248 / e52a914 deprecate url_close(). + 434f248 / 58a48c6 deprecate url_seek(). + 434f248 / 925e908 deprecate url_write(). + 434f248 / dce3756 deprecate url_read_complete(). + 434f248 / bc371ac deprecate url_read(). + 434f248 / 0589da0 deprecate url_open(). + 434f248 / 62eaaea deprecate url_connect. + 434f248 / 5652bb9 deprecate url_alloc. + 434f248 / 333e894 deprecate url_open_protocol + 434f248 / e230705 deprecate url_poll and URLPollEntry 2011-04-08 - lavf 52.106.0 - avformat.h Minor avformat.h cleanup: - a9bf9d8 deprecate av_guess_image2_codec - c3675df rename avf_sdp_create->av_sdp_create + d4d0932 / a9bf9d8 deprecate av_guess_image2_codec + d4d0932 / c3675df rename avf_sdp_create->av_sdp_create 2011-04-03 - lavf 52.105.0 - avio.h Large-scale renaming/deprecating of AVIOContext-related functions: - 724f6a0 deprecate url_fdopen - 403ee83 deprecate url_open_dyn_packet_buf - 6dc7d80 rename url_close_dyn_buf -> avio_close_dyn_buf - b92c545 rename url_open_dyn_buf -> avio_open_dyn_buf - 8978fed introduce an AVIOContext.seekable field as a replacement for + 2cae980 / 724f6a0 deprecate url_fdopen + 2cae980 / 403ee83 deprecate url_open_dyn_packet_buf + 2cae980 / 6dc7d80 rename url_close_dyn_buf -> avio_close_dyn_buf + 2cae980 / b92c545 rename url_open_dyn_buf -> avio_open_dyn_buf + 2cae980 / 8978fed introduce an AVIOContext.seekable field as a replacement for AVIOContext.is_streamed and url_is_streamed() - b64030f deprecate get_checksum() - 4c4427a deprecate init_checksum() - 4ec153b deprecate udp_set_remote_url/get_local_port - 933e90a deprecate av_url_read_fseek/fpause - 8d9769a deprecate url_fileno - b7f2fdd rename put_flush_packet -> avio_flush - 35f1023 deprecate url_close_buf - 83fddae deprecate url_open_buf - d9d86e0 rename url_fprintf -> avio_printf - 59f65d9 deprecate url_setbufsize - 3e68b3b deprecate url_ferror + 1caa412 / b64030f deprecate get_checksum() + 1caa412 / 4c4427a deprecate init_checksum() + 2fd41c9 / 4ec153b deprecate udp_set_remote_url/get_local_port + 4fa0e24 / 933e90a deprecate av_url_read_fseek/fpause + 4fa0e24 / 8d9769a deprecate url_fileno + 0fecf26 / b7f2fdd rename put_flush_packet -> avio_flush + 0fecf26 / 35f1023 deprecate url_close_buf + 0fecf26 / 83fddae deprecate url_open_buf + 0fecf26 / d9d86e0 rename url_fprintf -> avio_printf + 0fecf26 / 59f65d9 deprecate url_setbufsize + 6947b0c / 3e68b3b deprecate url_ferror e8bb2e2 deprecate url_fget_max_packet_size 76aa876 rename url_fsize -> avio_size e519753 deprecate url_fgetc @@ -727,7 +727,7 @@ API changes, most recent first: b3db9ce deprecate get_partial_buffer 8d9ac96 rename av_alloc_put_byte -> avio_alloc_context -2011-03-25 - 34b47d7 - lavc 52.115.0 - AVCodecContext.audio_service_type +2011-03-25 - 27ef7b1 / 34b47d7 - lavc 52.115.0 - AVCodecContext.audio_service_type Add audio_service_type field to AVCodecContext. 2011-03-17 - e309fdc - lavu 50.40.0 - pixfmt.h @@ -765,11 +765,11 @@ API changes, most recent first: 2011-02-10 - 12c14cd - lavf 52.99.0 - AVStream.disposition Add AV_DISPOSITION_HEARING_IMPAIRED and AV_DISPOSITION_VISUAL_IMPAIRED. -2011-02-09 - 5592734 - lavc 52.112.0 - avcodec_thread_init() +2011-02-09 - c0b102c - lavc 52.112.0 - avcodec_thread_init() Deprecate avcodec_thread_init()/avcodec_thread_free() use; instead set thread_count before calling avcodec_open. -2011-02-09 - 778b08a - lavc 52.111.0 - threading API +2011-02-09 - 37b00b4 - lavc 52.111.0 - threading API Add CODEC_CAP_FRAME_THREADS with new restrictions on get_buffer()/ release_buffer()/draw_horiz_band() callbacks for appropriate codecs. Add thread_type and active_thread_type fields to AVCodecContext. diff --git a/doc/RELEASE_NOTES b/doc/RELEASE_NOTES index 135165afa1..e3492d5a65 100644 --- a/doc/RELEASE_NOTES +++ b/doc/RELEASE_NOTES @@ -1,7 +1,7 @@ Release Notes ============= -* 0.10 "Freedom" January, 2012 +* 1.0 "Angel" September, 2012 General notes diff --git a/doc/decoders.texi b/doc/decoders.texi index 87ad4eea26..f246fc443a 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -60,4 +60,67 @@ This decoder generates wave patterns according to predefined sequences. Its use is purely internal and the format of the data it accepts is not publicly documented. +@section libcelt + +libcelt decoder wrapper + +libcelt allows libavcodec to decode the Xiph CELT ultra-low delay audio codec. +Requires the presence of the libcelt headers and library during configuration. +You need to explicitly configure the build with @code{--enable-libcelt}. + +@section libgsm + +libgsm decoder wrapper + +libgsm allows libavcodec to decode the GSM full rate audio codec. Requires +the presence of the libgsm headers and library during configuration. You need +to explicitly configure the build with @code{--enable-libgsm}. + +This decoder supports both the ordinary GSM and the Microsoft variant. + +@section libilbc + +libilbc decoder wrapper + +libilbc allows libavcodec to decode the Internet Low Bitrate Codec (iLBC) +audio codec. Requires the presence of the libilbc headers and library during +configuration. You need to explicitly configure the build with +@code{--enable-libilbc}. + +@subsection Options + +The following option is supported by the libilbc wrapper. + +@table @option +@item enhance + +Enable the enhancement of the decoded audio when set to 1. The default +value is 0 (disabled). + +@end table + +@section libopencore-amrnb + +libopencore-amrnb decoder wrapper + +libopencore-amrnb allows libavcodec to decode the Adaptive Multi-Rate +Narrowband audio codec. Using it requires the presence of the +libopencore-amrnb headers and library during configuration. You need to +explicitly configure the build with @code{--enable-libopencore-amrnb}. + +An FFmpeg native decoder for AMR-NB exists, so users can decode AMR-NB +without this library. + +@section libopencore-amrwb + +libopencore-amrwb decoder wrapper. + +libopencore-amrwb allows libavcodec to decode the Adaptive Multi-Rate +Wideband audio codec. Using it requires the presence of the +libopencore-amrwb headers and library during configuration. You need to +explicitly configure the build with @code{--enable-libopencore-amrwb}. + +An FFmpeg native decoder for AMR-WB exists, so users can decode AMR-WB +without this library. + @c man end AUDIO DECODERS diff --git a/doc/encoders.texi b/doc/encoders.texi index a7a2761f1d..6ed45d8d8f 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -412,6 +412,194 @@ Selected by Encoder (default) @end table +@section libmp3lame + +LAME (Lame Ain't an MP3 Encoder) MP3 encoder wrapper + +Requires the presence of the libmp3lame headers and library during +configuration. You need to explicitly configure the build with +@code{--enable-libmp3lame}. + +@subsection Option Mapping + +The following options are supported by the libmp3lame wrapper, +the LAME-equivalent options follow the FFmpeg ones. + +@multitable @columnfractions .2 .2 +@item FFmpeg @tab LAME +@item b @tab b +FFmpeg @code{b} option is expressed in bits/s, lame @code{bitrate} +in kilobits/s. +@item q @tab V +Quality setting for VBR. +@item compression_level @tab q +Algorithm quality. Valid options are integers from 0-9. +@item reservoir @tab N.A. +Enable use of bit reservoir. LAME has this enabled by default. +@item joint_stereo @tab -m j +Enables the the encoder to use (on a frame by frame basis) either L/R +stereo or mid/side stereo. +@end multitable + +@section libopencore-amrnb + +OpenCORE Adaptive Multi-Rate Narrowband encoder. + +Requires the presence of the libopencore-amrnb headers and library during +configuration. You need to explicitly configure the build with +@code{--enable-libopencore-amrnb --enable-version3}. + +This is a mono-only encoder. Officially it only supports 8000Hz sample rate, +but you can override it by setting @option{strict} to @samp{unofficial} or +lower. + +@subsection Options + +@table @option + +@item b +Set bitrate in bits per second. Only the following bitrates are supported, +otherwise libavcodec will round to the nearest valid bitrate. + +@table @option +@item 4750 +@item 5150 +@item 5900 +@item 6700 +@item 7400 +@item 7950 +@item 10200 +@item 12200 +@end table + +@item dtx +Allow discontinuous transmission (generate comfort noise) when set to 1. The +default value is 0 (disabled). + +@end table + +@section libtwolame + +TwoLAME MP2 encoder wrapper + +Requires the presence of the libtwolame headers and library during +configuration. You need to explicitly configure the build with +@code{--enable-libtwolame}. + +@subsection Options Mapping + +The following options are supported by the libtwolame wrapper. The +TwoLAME-equivalent options follow the FFmpeg ones and are in +parentheses. + +@table @option +@item b +(b) Set bitrate in bits/s. Note that FFmpeg @code{b} option is +expressed in bits/s, twolame @code{b} in kilobits/s. The default +value is 128k. + +@item q +(V) Set quality for experimental VBR support. Maximum value range is +from -50 to 50, useful range is from -10 to 10. + +@item mode +(mode) Set MPEG mode. Possible values: + +@table @samp +@item auto +Choose mode automatically based on the input. This is the default. +@item stereo +Stereo +@item joint_stereo +Joint stereo +@item dual_channel +Dual channel +@item mono +Mono +@end table + +@item psymodel +(psyc-mode) Set psychoacoustic model to use in encoding. The argument +must be an integer between -1 and 4, inclusive. The higher the value, +the better the quality. The default value is 3. + +@item energy_levels +(energy) Enable energy levels extensions when set to 1. The default +value is 0 (disabled). + +@item error_protection +(protect) Enable CRC error protection when set to 1. The default value +is 0 (disabled). + +@item copyright +(copyright) Set MPEG audio copyright flag when set to 1. The default +value is 0 (disabled). + +@item original +(original) Set MPEG audio original flag when set to 1. The default +value is 0 (disabled). + +@end table + +@section libvo-aacenc + +VisualOn AAC encoder + +Requires the presence of the libvo-aacenc headers and library during +configuration. You need to explicitly configure the build with +@code{--enable-libvo-aacenc --enable-version3}. + +@subsection Options + +The VisualOn AAC encoder only support encoding AAC-LC and up to 2 +channels. It is also CBR-only. It is considered to be worse than the +native experimental FFmpeg AAC encoder. + +@table @option + +@item b +Bitrate. + +@end table + +@section libvo-amrwbenc + +VisualOn Adaptive Multi-Rate Wideband encoder + +Requires the presence of the libvo-amrwbenc headers and library during +configuration. You need to explicitly configure the build with +@code{--enable-libvo-amrwbenc --enable-version3}. + +This is a mono-only encoder. Officially it only supports 16000Hz sample +rate, but you can override it by setting @option{strict} to +@samp{unofficial} or lower. + +@subsection Options + +@table @option + +@item b +Set bitrate in bits/s. Only the following bitrates are supported, otherwise +libavcodec will round to the nearest valid bitrate. + +@table @samp +@item 6600 +@item 8850 +@item 12650 +@item 14250 +@item 15850 +@item 18250 +@item 19850 +@item 23050 +@item 23850 +@end table + +@item dtx +Allow discontinuous transmission (generate comfort noise) when set to 1. The +default value is 0 (disabled). + +@end table + @c man end AUDIO ENCODERS @chapter Video Encoders @@ -591,4 +779,116 @@ ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv For more information about libx264 and the supported options see: @url{http://www.videolan.org/developers/x264.html} +@section libxvid + +Xvid MPEG-4 Part 2 encoder wrapper. + +This encoder requires the presence of the libxvidcore headers and library +during configuration. You need to explicitly configure the build with +@code{--enable-libxvid --enable-gpl}. + +The native @code{mpeg4} encoder supports the MPEG-4 Part 2 format, so +users can encode to this format without this library. + +@subsection Options + +The following options are supported by the libxvid wrapper. Some of +the following options are listed but are not documented, and +correspond to shared codec options. The other shared options +which are not listed have no effect for the libxvid encoder. + +@table @option +@item b + +@item g + +@item qmin + +@item qmax + +@item mpeg_quant + +@item threads + +@item bf + +@item b_qfactor + +@item b_qoffset + +@item flags +Set specific encoding flags. Possible values: + +@table @samp + +@item mv4 +Use four motion vector by macroblock. + +@item aic +Enable high quality AC prediction. + +@item gray +Only encode grayscale. + +@item gmc +Enable the use of global motion compensation (GMC). + +@item qpel +Enable quarter-pixel motion compensation. + +@item cgop +Enable closed GOP. + +@item global_header +Place global headers in extradata instead of every keyframe. + +@end table + +@item trellis + +@item me_method +Set motion estimation method. Possible values in decreasing order of +speed and increasing order of quality: + +@table @samp +@item zero +Use no motion estimation (default). + +@item phods +@item x1 +@item log +Enable advanced diamond zonal search for 16x16 blocks and half-pixel +refinement for 16x16 blocks. @samp{x1} and @samp{log} are aliases for +@samp{phods}. + +@item epzs +Enable all of the things described above, plus advanced diamond zonal +search for 8x8 blocks, half-pixel refinement for 8x8 blocks, and motion +estimation on chroma planes. + +@item full +Enable all of the things described above, plus extended 16x16 and 8x8 +blocks search. +@end table + +@item mbd +Set macroblock decision algorithm. Possible values in the increasing +order of quality: + +@table @samp +@item simple +Use macroblock comparing function algorithm (default). + +@item bits +Enable rate distortion-based half pixel and quarter pixel refinement for +16x16 blocks. + +@item rd +Enable all of the things described above, plus rate distortion-based +half pixel and quarter pixel refinement for 8x8 blocks, and rate +distortion-based search using square pattern. +@end table + +@end table + @c man end VIDEO ENCODERS diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 121fbc10ae..d125acde2a 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1013,7 +1013,7 @@ ffmpeg -filter_complex 'color=red' -t 5 out.mkv As a special exception, you can use a bitmap subtitle stream as input: it will be converted into a video with the same size as the largest video in -the file, or 720×576 if no video is present. Note that this is an +the file, or 720x576 if no video is present. Note that this is an experimental and temporary solution. It will be removed once libavfilter has proper support for subtitles. diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd index 403d59e3e5..595d66fd8c 100644 --- a/doc/ffprobe.xsd +++ b/doc/ffprobe.xsd @@ -100,8 +100,6 @@ - - @@ -112,7 +110,6 @@ - diff --git a/doc/filters.texi b/doc/filters.texi index 916aa6f8b9..64ce647d0b 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16,10 +16,10 @@ To illustrate the sorts of things that are possible, we can use a complex filter graph. For example, the following one: @example -input --> split --> fifo -----------------------> overlay --> output - | ^ - | | - +------> fifo --> crop --> vflip --------+ +input --> split ---------------------> overlay --> output + | ^ + | | + +-----> crop --> vflip -------+ @end example splits the stream in two streams, sends one stream through the crop filter @@ -27,7 +27,7 @@ and the vflip filter before merging it back with the other stream by overlaying it on top. You can use the following command to achieve this: @example -ffmpeg -i input -vf "[in] split [T1], fifo, [T2] overlay=0:H/2 [out]; [T1] fifo, crop=iw:ih/2:0:ih/2, vflip [T2]" output +ffmpeg -i input -vf "[in] split [T1], [T2] overlay=0:H/2 [out]; [T1] crop=iw:ih/2:0:ih/2, vflip [T2]" output @end example The result will be that in output the top half of the video is mirrored @@ -35,8 +35,8 @@ onto the bottom half. Filters are loaded using the @var{-vf} or @var{-af} option passed to @command{ffmpeg} or to @command{ffplay}. Filters in the same linear -chain are separated by commas. In our example, @var{split, fifo, -overlay} are in one linear chain, and @var{fifo, crop, vflip} are in +chain are separated by commas. In our example, @var{split, +overlay} are in one linear chain, and @var{crop, vflip} are in another. The points where the linear chains join are labeled by names enclosed in square brackets. In our example, that is @var{[T1]} and @var{[T2]}. The special labels @var{[in]} and @var{[out]} are the points @@ -3458,7 +3458,7 @@ Tile several successive frames together. It accepts as argument the tile size (i.e. the number of lines and columns) in the form "@var{w}x@var{h}". -For example, produce 8×8 PNG tiles of all keyframes (@option{-skip_frame +For example, produce 8x8 PNG tiles of all keyframes (@option{-skip_frame nokey}) in a movie: @example ffmpeg -skip_frame nokey -i file.avi -vf 'scale=128:72,tile=8x8' -an -vsync 0 keyframes%03d.png @@ -4554,7 +4554,7 @@ streams in each segment. Default is 0. The filter has @var{v}+@var{a} outputs: first @var{v} video outputs, then @var{a} audio outputs. -There are @var{n}×(@var{v}+@var{a}) inputs: first the inputs for the first +There are @var{n}x(@var{v}+@var{a}) inputs: first the inputs for the first segment, in the same order as the outputs, then the inputs for the second segment, etc. diff --git a/doc/general.texi b/doc/general.texi index 74ab3e0790..2390c98f7c 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -24,7 +24,7 @@ instructions. To enable using OpenJPEG in FFmpeg, pass @code{--enable-libopenjp @file{./configure}. -@section OpenCORE and VisualOn libraries +@section OpenCORE, VisualOn, and Fraunhofer libraries Spun off Google Android sources, OpenCore, VisualOn and Fraunhofer libraries provide encoders for a number of audio codecs. @@ -32,9 +32,14 @@ libraries provide encoders for a number of audio codecs. @float NOTE OpenCORE and VisualOn libraries are under the Apache License 2.0 (see @url{http://www.apache.org/licenses/LICENSE-2.0} for details), which is -incompatible with the LGPL version 2.1 and GPL version 2. You have to +incompatible to the LGPL version 2.1 and GPL version 2. You have to upgrade FFmpeg's license to LGPL version 3 (or if you have enabled -GPL components, GPL version 3) to use it. +GPL components, GPL version 3) by passing @code{--enable-version3} to configure in +order to use it. + +The Fraunhofer AAC library is licensed under a license incompatible to the GPL +and is not known to be compatible to the LGPL. Therefore, you have to pass +@code{--enable-nonfree} to configure to use it. @end float @subsection OpenCORE AMR diff --git a/doc/issue_tracker.txt b/doc/issue_tracker.txt index d487f66830..27b0009b58 100644 --- a/doc/issue_tracker.txt +++ b/doc/issue_tracker.txt @@ -24,7 +24,7 @@ a mail for every change to every issue. The subscription URL for the ffmpeg-trac list is: http(s)://ffmpeg.org/mailman/listinfo/ffmpeg-trac The URL of the webinterface of the tracker is: -http(s)://ffmpeg.org/trac/ffmpeg +http(s)://trac.ffmpeg.org Type: ----- diff --git a/doc/muxers.texi b/doc/muxers.texi index 83c21dba67..8fd7ecd312 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -18,6 +18,23 @@ enabled muxers. A description of some of the currently available muxers follows. +@anchor{aiff} +@section aiff + +Audio Interchange File Format muxer. + +It accepts the following options: + +@table @option +@item write_id3v2 +Enable ID3v2 tags writing when set to 1. Default is 0 (disabled). + +@item id3v2_version +Select ID3v2 version to write. Currently only version 3 and 4 (aka. +ID3v2.3 and ID3v2.4) are supported. The default is version 4. + +@end table + @anchor{crc} @section crc @@ -641,10 +658,11 @@ Write an mp3 with an ID3v2.3 header and an ID3v1 footer: ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3 @end example -Attach a picture to an mp3: +To attach a picture to an mp3 file select both the audio and the picture stream +with @code{map}: @example -ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover" --metadata:s:v comment="Cover (Front)" out.mp3 +ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1 +-metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3 @end example @c man end MUXERS diff --git a/doc/texi2pod.pl b/doc/texi2pod.pl index 5e8814feff..610f349afb 100755 --- a/doc/texi2pod.pl +++ b/doc/texi2pod.pl @@ -27,9 +27,9 @@ use warnings; $output = 0; $skipping = 0; -%sects = (); -@sects_sequence = (); -$section = ""; +%chapters = (); +@chapters_sequence = (); +$chapter = ""; @icstack = (); @endwstack = (); @skstack = (); @@ -116,18 +116,24 @@ INF: while(<$inf>) { die "cannot open $1: $!\n"; }; - # Look for blocks surrounded by @c man begin SECTION ... @c man end. - # This really oughta be @ifman ... @end ifman and the like, but such - # would require rev'ing all other Texinfo translators. - /^\@c\s+man\s+begin\s+([A-Za-z ]+)/ and $sect = $1, push (@sects_sequence, $sect), $output = 1, next; - /^\@c\s+man\s+end/ and do { - $sects{$sect} = "" unless exists $sects{$sect}; - $sects{$sect} .= postprocess($section); - $section = ""; - $output = 0; + /^\@chapter\s+([A-Za-z ]+)/ and do { + # close old chapter + $chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name); + + # start new chapter + $chapter_name = $1, push (@chapters_sequence, $chapter_name) unless $skipping; + $chapters{$chapter_name} = "" unless exists $chapters{$chapter_name}; + $chapter = ""; + $output = 1; next; }; + /^\@bye/ and do { + # close old chapter + $chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name); + last INF; + }; + # handle variables /^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do { $defs{$1} = $2; @@ -150,20 +156,20 @@ INF: while(<$inf>) { # Ignore @end foo, where foo is not an operation which may # cause us to skip, if we are presently skipping. my $ended = $1; - next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/; + next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|ifhtml|ifnothtml)$/; die "\@end $ended without \@$ended at line $.\n" unless defined $endw; die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw; $endw = pop @endwstack; - if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) { + if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex|ifhtml|ifnothtml)$/) { $skipping = pop @skstack; next; } elsif ($ended =~ /^(?:example|smallexample|display)$/) { $shift = ""; $_ = ""; # need a paragraph break - } elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) { + } elsif ($ended =~ /^(?:itemize|enumerate|(?:multi|[fv])?table)$/) { $_ = "\n=back\n"; $ic = pop @icstack; } else { @@ -190,11 +196,11 @@ INF: while(<$inf>) { next; }; - /^\@(ignore|menu|iftex)\b/ and do { + /^\@(ignore|menu|iftex|ifhtml|ifnothtml)\b/ and do { push @endwstack, $endw; push @skstack, $skipping; $endw = $1; - $skipping = 1; + $skipping = $endw !~ /ifnothtml/; next; }; @@ -211,7 +217,6 @@ INF: while(<$inf>) { s/\@TeX\{\}/TeX/g; s/\@pounds\{\}/\#/g; s/\@minus(?:\{\})?/-/g; - s/\\,/,/g; # Now the ones that have to be replaced by special escapes # (which will be turned back into text by unmunge()) @@ -264,15 +269,16 @@ INF: while(<$inf>) { $endw = "enumerate"; }; - /^\@([fv]?table)\s+(\@[a-z]+)/ and do { + /^\@((?:multi|[fv])?table)\s+(\@[a-z]+)/ and do { push @endwstack, $endw; push @icstack, $ic; $endw = $1; $ic = $2; - $ic =~ s/\@(?:samp|strong|key|gcctabopt|option|env)/B/; + $ic =~ s/\@(?:samp|strong|key|gcctabopt|option|env|command)/B/; $ic =~ s/\@(?:code|kbd)/C/; $ic =~ s/\@(?:dfn|var|emph|cite|i)/I/; $ic =~ s/\@(?:file)/F/; + $ic =~ s/\@(?:columnfractions)//; $_ = "\n=over 4\n"; }; @@ -283,6 +289,21 @@ INF: while(<$inf>) { $_ = ""; # need a paragraph break }; + /^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do { + my $columns = $1; + $columns =~ s/\@tab/ : /; + + $_ = "\n=item B<". $columns .">\n"; + }; + + /^\@tab\s+(.*\S)\s*$/ and $endw eq "multitable" and do { + my $columns = $1; + $columns =~ s/\@tab/ : /; + + $_ = " : ". $columns; + $chapter =~ s/\n+\s+$//; + }; + /^\@itemx?\s*(.+)?$/ and do { if (defined $1) { # Entity escapes prevent munging by the <> processing below. @@ -294,7 +315,7 @@ INF: while(<$inf>) { } }; - $section .= $shift.$_."\n"; + $chapter .= $shift.$_."\n"; } # End of current file. close($inf); @@ -303,16 +324,15 @@ $inf = pop @instack; die "No filename or title\n" unless defined $fn && defined $tl; -$sects{NAME} = "$fn \- $tl\n"; -$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES}; +$chapters{NAME} = "$fn \- $tl\n"; +$chapters{FOOTNOTES} .= "=back\n" if exists $chapters{FOOTNOTES}; -unshift @sects_sequence, "NAME"; -for $sect (@sects_sequence) { - if(exists $sects{$sect}) { - $head = $sect; - $head =~ s/SEEALSO/SEE ALSO/; +unshift @chapters_sequence, "NAME"; +for $chapter (@chapters_sequence) { + if (exists $chapters{$chapter}) { + $head = uc($chapter); print "=head1 $head\n\n"; - print scalar unmunge ($sects{$sect}); + print scalar unmunge ($chapters{$chapter}); print "\n"; } } @@ -357,6 +377,7 @@ sub postprocess s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g; s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g; s/;\s+\@pxref\{(?:[^\}]*)\}//g; + s/\@ref\{(?:[^,\}]*,)(?:[^,\}]*,)([^,\}]*).*\}/$1/g; s/\@ref\{([^\}]*)\}/$1/g; s/\@noindent\s*//g; s/\@refill//g; @@ -366,7 +387,7 @@ sub postprocess # @uref can take one, two, or three arguments, with different # semantics each time. @url and @email are just like @uref with # one argument, for our purposes. - s/\@(?:uref|url|email)\{([^\},]*)\}/<B<$1>>/g; + s/\@(?:uref|url|email)\{([^\},]*),?[^\}]*\}/<B<$1>>/g; s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g; s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g; @@ -410,13 +431,13 @@ sub unmunge sub add_footnote { - unless (exists $sects{FOOTNOTES}) { - $sects{FOOTNOTES} = "\n=over 4\n\n"; + unless (exists $chapters{FOOTNOTES}) { + $chapters{FOOTNOTES} = "\n=over 4\n\n"; } - $sects{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++; - $sects{FOOTNOTES} .= $_[0]; - $sects{FOOTNOTES} .= "\n\n"; + $chapters{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++; + $chapters{FOOTNOTES} .= $_[0]; + $chapters{FOOTNOTES} .= "\n\n"; } # stolen from Symbol.pm diff --git a/ffmpeg.c b/ffmpeg.c index 3eb15a6494..04adc548d4 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -151,6 +151,8 @@ static struct termios oldtty; static int restore_tty; #endif +static void free_input_threads(void); + /* sub2video hack: Convert subtitles to video with alpha to insert them in filter graphs. @@ -424,6 +426,9 @@ void av_noreturn exit_program(int ret) av_freep(&output_streams[i]->logfile_prefix); av_freep(&output_streams[i]); } +#if HAVE_PTHREADS + free_input_threads(); +#endif for (i = 0; i < nb_input_files; i++) { avformat_close_input(&input_files[i]->ctx); av_freep(&input_files[i]); diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 2c5fbfb6b2..6ccb3f480f 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1141,9 +1141,11 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in if (do_pass) { if (do_pass & 1) { video_enc->flags |= CODEC_FLAG_PASS1; + av_dict_set(&ost->opts, "flags", "+pass1", AV_DICT_APPEND); } if (do_pass & 2) { video_enc->flags |= CODEC_FLAG_PASS2; + av_dict_set(&ost->opts, "flags", "+pass2", AV_DICT_APPEND); } } @@ -1636,6 +1638,7 @@ loop_end: ost = new_attachment_stream(o, oc, -1); ost->stream_copy = 0; ost->attachment_filename = o->attachments[i]; + ost->finished = 1; ost->st->codec->extradata = attachment; ost->st->codec->extradata_size = len; diff --git a/ffplay.c b/ffplay.c index 2337fe0d27..83bfd4e216 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1617,7 +1617,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:pixel_aspect=%d/%d", codec->width, codec->height, codec->pix_fmt, is->video_st->time_base.num, is->video_st->time_base.den, - codec->sample_aspect_ratio.num, codec->sample_aspect_ratio.den); + codec->sample_aspect_ratio.num, FFMAX(codec->sample_aspect_ratio.den, 1)); if ((ret = avfilter_graph_create_filter(&filt_src, avfilter_get_by_name("buffer"), diff --git a/ffprobe.c b/ffprobe.c index e9f66b0342..7c419c815a 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1621,10 +1621,6 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i print_str("codec_tag_string", val_str); print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag); - /* Print useful disposition */ - print_int("default", !!(stream->disposition & AV_DISPOSITION_DEFAULT)); - print_int("forced", !!(stream->disposition & AV_DISPOSITION_FORCED)); - switch (dec_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: print_int("width", dec_ctx->width); @@ -1653,8 +1649,6 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i } else { print_str_opt("timecode", "N/A"); } - print_int("attached_pic", - !!(stream->disposition & AV_DISPOSITION_ATTACHED_PIC)); break; case AVMEDIA_TYPE_AUDIO: diff --git a/ffserver.c b/ffserver.c index 1eae3adff3..87401402f8 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2034,7 +2034,7 @@ static void compute_status(HTTPContext *c) char cpuperc[10]; char cpuused[64]; - if (fscanf(pid_stat, "%10s %64s", cpuperc, + if (fscanf(pid_stat, "%9s %63s", cpuperc, cpuused) == 2) { avio_printf(pb, "Currently using %s%% of the cpu. Total time used %s.\n", cpuperc, cpuused); @@ -2937,12 +2937,14 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, { AVFormatContext *avc; AVStream *avs = NULL; + AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); int i; avc = avformat_alloc_context(); - if (avc == NULL) { + if (avc == NULL || !rtp_format) { return -1; } + avc->oformat = rtp_format; av_dict_set(&avc->metadata, "title", stream->title[0] ? stream->title : "No Title", 0); avc->nb_streams = stream->nb_streams; diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index e66dcb8405..417c457cc6 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -713,7 +713,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, const float lambda) { int start = 0, i, w, w2, g; - int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels; + int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels * (lambda / 120.f); float dists[128] = { 0 }, uplims[128]; float maxvals[128]; int fflag, minscaler; diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 62df283b78..4f0cf4b418 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -112,6 +112,10 @@ static VLC vlc_scalefactors; static VLC vlc_spectral[11]; +static int output_configure(AACContext *ac, + uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, + int channel_config, enum OCStatus oc_type); + #define overread_err "Input buffer exhausted before END element found\n" static int count_channels(uint8_t (*layout)[3], int tags) @@ -373,6 +377,8 @@ static void pop_output_configuration(AACContext *ac) { ac->oc[1] = ac->oc[0]; ac->avctx->channels = ac->oc[1].channels; ac->avctx->channel_layout = ac->oc[1].channel_layout; + output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, + ac->oc[1].m4ac.chan_config, ac->oc[1].status); } } @@ -883,6 +889,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) } } + if (avctx->channels > MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "Too many channels\n"); + return AVERROR_INVALIDDATA; + } + AAC_INIT_VLC_STATIC( 0, 304); AAC_INIT_VLC_STATIC( 1, 270); AAC_INIT_VLC_STATIC( 2, 550); diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 9b2b2bbab5..d09d3fd23c 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -522,7 +522,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, /* add current frame to queue */ if (frame) { - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } @@ -576,7 +576,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } start_ch += chans; } - if ((ret = ff_alloc_packet2(avctx, avpkt, 768 * s->channels))) { + if ((ret = ff_alloc_packet2(avctx, avpkt, 8192 * s->channels))) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); return ret; } diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index b4fc761fa1..c982ba5a50 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -1124,7 +1124,12 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { float temp1 = exp2f(sbr->data[0].env_facs[e][k] * alpha + 7.0f); float temp2 = exp2f((pan_offset - sbr->data[1].env_facs[e][k]) * alpha); - float fac = temp1 / (1.0f + temp2); + float fac; + if (temp1 > 1E20) { + av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); + temp1 = 1; + } + fac = temp1 / (1.0f + temp2); sbr->data[0].env_facs[e][k] = fac; sbr->data[1].env_facs[e][k] = fac * temp2; } @@ -1133,7 +1138,12 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (k = 0; k < sbr->n_q; k++) { float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k] + 1); float temp2 = exp2f(12 - sbr->data[1].noise_facs[e][k]); - float fac = temp1 / (1.0f + temp2); + float fac; + if (temp1 > 1E20) { + av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); + temp1 = 1; + } + fac = temp1 / (1.0f + temp2); sbr->data[0].noise_facs[e][k] = fac; sbr->data[1].noise_facs[e][k] = fac * temp2; } @@ -1142,9 +1152,15 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) { float alpha = sbr->data[ch].bs_amp_res ? 1.0f : 0.5f; for (e = 1; e <= sbr->data[ch].bs_num_env; e++) - for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++) + for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){ sbr->data[ch].env_facs[e][k] = exp2f(alpha * sbr->data[ch].env_facs[e][k] + 6.0f); + if (sbr->data[ch].env_facs[e][k] > 1E20) { + av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); + sbr->data[ch].env_facs[e][k] = 1; + } + } + for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) for (k = 0; k < sbr->n_q; k++) sbr->data[ch].noise_facs[e][k] = diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index c779f8b572..683a231f26 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -755,7 +755,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } } - for (n = nb_samples >> (1 - st); n > 0; n--) { + for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) { int v = bytestream2_get_byteu(&gb); *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 9cd17374a8..6e72bb6a6f 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -224,7 +224,7 @@ static void lpc_prediction(int32_t *error_buffer, int32_t *buffer_out, } /* read warm-up samples */ - for (i = 1; i <= lpc_order; i++) + for (i = 1; i <= lpc_order && i < nb_samples; i++) buffer_out[i] = sign_extend(buffer_out[i - 1] + error_buffer[i], bps); /* NOTE: 4 and 8 are very common cases that could be optimized. */ @@ -542,7 +542,11 @@ static av_cold int alac_decode_close(AVCodecContext *avctx) static int allocate_buffers(ALACContext *alac) { int ch; - int buf_size = alac->max_samples_per_frame * sizeof(int32_t); + int buf_size; + + if (alac->max_samples_per_frame > INT_MAX / sizeof(int32_t)) + goto buf_alloc_fail; + buf_size = alac->max_samples_per_frame * sizeof(int32_t); for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) { FF_ALLOC_OR_GOTO(alac->avctx, alac->predict_error_buffer[ch], diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 79b6ba8dd8..c472ad95af 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -262,7 +262,7 @@ static void alac_linear_predictor(AlacEncodeContext *s, int ch) // generate warm-up samples residual[0] = samples[0]; for (i = 1; i <= lpc.lpc_order; i++) - residual[i] = samples[i] - samples[i-1]; + residual[i] = sign_extend(samples[i] - samples[i-1], s->write_sample_size); // perform lpc on remaining samples for (i = lpc.lpc_order + 1; i < s->frame_size; i++) { diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 46dd0b45ae..a8056889a7 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -283,7 +283,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) GetBitContext gb; uint64_t ht_size; int i, config_offset; - MPEG4AudioConfig m4ac; + MPEG4AudioConfig m4ac = {0}; ALSSpecificConfig *sconf = &ctx->sconf; AVCodecContext *avctx = ctx->avctx; uint32_t als_id, header_size, trailer_size; @@ -552,12 +552,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks, /** Read the block data for a constant block */ -static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd) +static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd) { ALSSpecificConfig *sconf = &ctx->sconf; AVCodecContext *avctx = ctx->avctx; GetBitContext *gb = &ctx->gb; + if (bd->block_length <= 0) + return -1; + *bd->raw_samples = 0; *bd->const_block = get_bits1(gb); // 1 = constant value, 0 = zero block (silence) bd->js_blocks = get_bits1(gb); @@ -572,6 +575,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd) // ensure constant block decoding by reusing this field *bd->const_block = 1; + + return 0; } @@ -971,7 +976,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd) if (read_var_block_data(ctx, bd)) return -1; } else { - read_const_block_data(ctx, bd); + if (read_const_block_data(ctx, bd) < 0) + return -1; } return 0; diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index 35725005e7..789cb9d456 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -407,7 +407,7 @@ static int decode_frame(AVCodecContext *avctx, switch(buf[0]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - if (s->nb_args < MAX_NB_ARGS) + if (s->nb_args < MAX_NB_ARGS && s->args[s->nb_args] < 6553) s->args[s->nb_args] = FFMAX(s->args[s->nb_args], 0) * 10 + buf[0] - '0'; break; case ';': diff --git a/libavcodec/arm/int_neon.S b/libavcodec/arm/int_neon.S index bce84516c6..2ccb4180cd 100644 --- a/libavcodec/arm/int_neon.S +++ b/libavcodec/arm/int_neon.S @@ -42,10 +42,10 @@ function ff_scalarproduct_int16_neon, export=1 vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 - vpadd.s32 d10, d4, d5 - vpadd.s32 d11, d6, d7 + vpadd.s32 d18, d4, d5 + vpadd.s32 d19, d6, d7 vpadd.s32 d0, d16, d17 - vpadd.s32 d1, d10, d11 + vpadd.s32 d1, d18, d19 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] @@ -82,10 +82,10 @@ function ff_scalarproduct_and_madd_int16_neon, export=1 vpadd.s32 d16, d0, d1 vpadd.s32 d17, d2, d3 - vpadd.s32 d10, d4, d5 - vpadd.s32 d11, d6, d7 + vpadd.s32 d18, d4, d5 + vpadd.s32 d19, d6, d7 vpadd.s32 d0, d16, d17 - vpadd.s32 d1, d10, d11 + vpadd.s32 d1, d18, d19 vpadd.s32 d2, d0, d1 vpaddl.s32 d3, d2 vmov.32 r0, d3[0] diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c index 7ee48b4a5c..dc38341e14 100644 --- a/libavcodec/ass_split.c +++ b/libavcodec/ass_split.c @@ -368,7 +368,7 @@ int ff_ass_split_override_codes(const ASSCodesCallbacks *callbacks, void *priv, char new_line[2]; int text_len = 0; - while (*buf) { + while (buf && *buf) { if (text && callbacks->text && (sscanf(buf, "\\%1[nN]", new_line) == 1 || !strncmp(buf, "{\\", 2))) { diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 7d076bed99..1da4c786eb 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -955,6 +955,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) } /* Check the extradata. */ + if (q->codingMode == JOINT_STEREO && avctx->channels < 2) { + av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n"); + return AVERROR_INVALIDDATA; + } + if (q->atrac3version != 4) { av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version); return AVERROR_INVALIDDATA; diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 516f1c972b..c8724de346 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -283,7 +283,7 @@ int av_packet_split_side_data(AVPacket *pkt){ for (i=0; ; i++){ size= AV_RB32(p); av_assert0(size<=INT_MAX && p - pkt->data >= size); - pkt->side_data[i].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + pkt->side_data[i].data = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); pkt->side_data[i].size = size; pkt->side_data[i].type = p[4]&127; if (!pkt->side_data[i].data) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 9990700797..c06348a753 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -169,7 +169,7 @@ static void init_lengths(BinkContext *c, int width, int bw) * * @param c decoder context */ -static av_cold void init_bundles(BinkContext *c) +static av_cold int init_bundles(BinkContext *c) { int bw, bh, blocks; int i; @@ -180,8 +180,12 @@ static av_cold void init_bundles(BinkContext *c) for (i = 0; i < BINKB_NB_SRC; i++) { c->bundle[i].data = av_malloc(blocks * 64); + if (!c->bundle[i].data) + return AVERROR(ENOMEM); c->bundle[i].data_end = c->bundle[i].data + blocks * 64; } + + return 0; } /** @@ -1272,7 +1276,7 @@ static av_cold int decode_init(AVCodecContext *avctx) BinkContext * const c = avctx->priv_data; static VLC_TYPE table[16 * 128][2]; static int binkb_initialised = 0; - int i; + int i, ret; int flags; c->version = avctx->codec_tag >> 24; @@ -1307,7 +1311,10 @@ static av_cold int decode_init(AVCodecContext *avctx) ff_dsputil_init(&c->dsp, avctx); ff_binkdsp_init(&c->bdsp); - init_bundles(c); + if ((ret = init_bundles(c)) < 0) { + free_bundles(c); + return ret; + } if (c->version == 'b') { if (!binkb_initialised) { diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index 385721fe1d..d8f34c8602 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -305,7 +305,7 @@ STOP_TIMER("get_cabac_bypass") for(i=0; i CDG_HEADER_SIZE) + bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE); if ((command & CDG_MASK) == CDG_COMMAND) { switch (inst) { diff --git a/libavcodec/dirac_arith.h b/libavcodec/dirac_arith.h index f9a8bba5fd..089c71a698 100644 --- a/libavcodec/dirac_arith.h +++ b/libavcodec/dirac_arith.h @@ -28,6 +28,7 @@ #ifndef AVCODEC_DIRAC_ARITH_H #define AVCODEC_DIRAC_ARITH_H +#include "libavutil/x86/asm.h" #include "bytestream.h" #include "get_bits.h" @@ -134,7 +135,7 @@ static inline int dirac_get_arith_bit(DiracArith *c, int ctx) range_times_prob = (c->range * prob_zero) >> 16; -#if HAVE_FAST_CMOV && HAVE_INLINE_ASM +#if HAVE_FAST_CMOV && HAVE_INLINE_ASM && HAVE_6REGS low -= range_times_prob << 16; range -= range_times_prob; bit = 0; diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index 13d9e478b5..48a609b1bb 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -1337,8 +1337,8 @@ static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5], motion_y >>= s->chroma_y_shift; } - mx = motion_x & ~(-1 << s->mv_precision); - my = motion_y & ~(-1 << s->mv_precision); + mx = motion_x & ~(-1U << s->mv_precision); + my = motion_y & ~(-1U << s->mv_precision); motion_x >>= s->mv_precision; motion_y >>= s->mv_precision; /* normalize subpel coordinates to epel */ diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index c8b031e739..2a7e7bb748 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -235,7 +235,7 @@ static int dnxhd_init_qmat(DNXHDEncContext *ctx, int lbias, int cbias) static int dnxhd_init_rc(DNXHDEncContext *ctx) { - FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail); + FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*(ctx->m.avctx->qmax + 1)*sizeof(RCEntry), fail); if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD) FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail); diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c index 451b7b976e..cc9457ab1b 100644 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@ -201,6 +201,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, buf[803] = s->bits_per_component; write16(buf + 804, (s->bits_per_component == 10 || s->bits_per_component == 12) ? 1 : 0); /* packing method */ + write32(buf + 808, HEADER_SIZE); /* data offset */ /* Image source information header */ write32(buf + 1628, avctx->sample_aspect_ratio.num); diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index af939b1f34..2a981902d4 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -1922,7 +1922,7 @@ void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){ static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){ long i; - for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ + for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){ long a = *(long*)(src+i); long b = *(long*)(dst+i); *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80); @@ -1947,7 +1947,7 @@ static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, } }else #endif - for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ + for(i=0; i<=w-(int)sizeof(long); i+=sizeof(long)){ long a = *(long*)(src1+i); long b = *(long*)(src2+i); *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80); diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index b3382406cd..47a9231868 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -237,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx, int chunk_type; int inter; - if (buf_size < 17) { + if (buf_size < 26) { av_log(avctx, AV_LOG_ERROR, "Input buffer too small\n"); *data_size = 0; return -1; diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 6ae06f2ad1..a166256a18 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -923,6 +923,12 @@ void ff_er_frame_end(MpegEncContext *s) return; }; + if ( s->picture_structure == PICT_FRAME + && s->current_picture.f.linesize[0] != s->current_picture_ptr->f.linesize[0]) { + av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n"); + return; + } + if (s->current_picture.f.motion_val[0] == NULL) { av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n"); diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 8f89542de7..57ea929109 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -471,7 +471,7 @@ static av_always_inline int encode_line(FFV1Context *s, int w, int run_mode=0; if(s->ac){ - if(c->bytestream_end - c->bytestream < w*20){ + if(c->bytestream_end - c->bytestream < w*35){ av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); return -1; } @@ -1242,7 +1242,7 @@ static int encode_slice(AVCodecContext *c, void *arg){ } if(!fs->ac){ if(f->version > 2) - put_rac(&fs->c, (int[]){129}, 0); + put_rac(&fs->c, (uint8_t[]){129}, 0); fs->ac_byte_count = f->version > 2 || (!x&&!y) ? ff_rac_terminate(&fs->c) : 0; init_put_bits(&fs->pb, fs->c.bytestream_start + fs->ac_byte_count, fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count); } @@ -1313,9 +1313,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, for(i=1; islice_count; i++){ FFV1Context *fs= f->slice_context[i]; - uint8_t *start = pkt->data + (pkt->size-used_count)*i/f->slice_count; + uint8_t *start = pkt->data + (pkt->size-used_count)*(int64_t)i/f->slice_count; int len = pkt->size/f->slice_count; - ff_init_range_encoder(&fs->c, start, len); } avctx->execute(avctx, encode_slice, &f->slice_context[0], NULL, f->slice_count, sizeof(void*)); @@ -1678,7 +1677,7 @@ static int decode_slice(AVCodecContext *c, void *arg){ if(!fs->ac){ if (f->version == 3 && f->minor_version > 1 || f->version > 3) - get_rac(&fs->c, (int[]){129}); + get_rac(&fs->c, (uint8_t[]){129}); fs->ac_byte_count = f->version > 2 || (!x&&!y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0; init_get_bits(&fs->gb, fs->c.bytestream_start + fs->ac_byte_count, @@ -1707,7 +1706,7 @@ static int decode_slice(AVCodecContext *c, void *arg){ } if(fs->ac && f->version > 2) { int v; - get_rac(&fs->c, (int[]){129}); + get_rac(&fs->c, (uint8_t[]){129}); v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5*f->ec; if(v) { av_log(f->avctx, AV_LOG_ERROR, "bytestream end mismatching by %d\n", v); diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index e37ca64be8..f38d7aae67 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -541,14 +541,18 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, av_freep(&fpc->best_header); } - /* Find and score new headers. */ - while ((buf && read_end < buf + buf_size && + /* Find and score new headers. */ + /* buf_size is to zero when padding, so check for this since we do */ + /* not want to try to read more input once we have found the end. */ + /* Note that as (non-modified) parameters, buf can be non-NULL, */ + /* while buf_size is 0. */ + while ((buf && buf_size && read_end < buf + buf_size && fpc->nb_headers_buffered < FLAC_MIN_HEADERS) - || (!buf && !fpc->end_padded)) { + || ((!buf || !buf_size) && !fpc->end_padded)) { int start_offset; /* Pad the end once if EOF, to check the final region for headers. */ - if (!buf) { + if (!buf || !buf_size) { fpc->end_padded = 1; buf_size = MAX_FRAME_HEADER_SIZE; read_end = read_start + MAX_FRAME_HEADER_SIZE; @@ -569,7 +573,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, goto handle_error; } - if (buf) { + if (buf && buf_size) { av_fifo_generic_write(fpc->fifo_buf, (void*) read_start, read_end - read_start, NULL); } else { diff --git a/libavcodec/flacdata.c b/libavcodec/flacdata.c index 6fcbe3955a..1954f32d32 100644 --- a/libavcodec/flacdata.c +++ b/libavcodec/flacdata.c @@ -27,7 +27,7 @@ const int ff_flac_sample_rate_table[16] = 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, 0, 0, 0, 0 }; -const int16_t ff_flac_blocksize_table[16] = { +const int32_t ff_flac_blocksize_table[16] = { 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0, 256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7 }; diff --git a/libavcodec/flacdata.h b/libavcodec/flacdata.h index 96a50b9183..e2c1e5d7f2 100644 --- a/libavcodec/flacdata.h +++ b/libavcodec/flacdata.h @@ -26,6 +26,6 @@ extern const int ff_flac_sample_rate_table[16]; -extern const int16_t ff_flac_blocksize_table[16]; +extern const int32_t ff_flac_blocksize_table[16]; #endif /* AVCODEC_FLACDATA_H */ diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 1d94efdb83..db956cb5bd 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -373,6 +373,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, if (has_diff) { s->diff_start = get_bits(&gb, 8); s->diff_height = get_bits(&gb, 8); + if (s->diff_start + s->diff_height > cur_blk_height) { + av_log(avctx, AV_LOG_ERROR, "Block parameters invalid\n"); + return AVERROR_INVALIDDATA; + } av_log(avctx, AV_LOG_DEBUG, "%dx%d diff start %d height %d\n", i, j, s->diff_start, s->diff_height); diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c index 29eb4fae2c..39fc437935 100644 --- a/libavcodec/g723_1.c +++ b/libavcodec/g723_1.c @@ -2289,7 +2289,8 @@ static int pack_bitstream(G723_1_Context *p, unsigned char *frame, int size) if (p->cur_rate == RATE_6300) { info_bits = 0; put_bits(&pb, 2, info_bits); - } + }else + av_assert0(0); put_bits(&pb, 8, p->lsp_index[2]); put_bits(&pb, 8, p->lsp_index[1]); diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index ef1b6ed62c..a28edbd682 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -724,10 +724,10 @@ frame_end: } if(startcode_found){ - av_fast_malloc( + av_fast_padded_mallocz( &s->bitstream_buffer, &s->allocated_bitstream_buffer_size, - buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE); + buf_size - current_pos); if (!s->bitstream_buffer) return AVERROR(ENOMEM); memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 713fda7421..39a2764c70 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -310,10 +310,11 @@ static inline int get_lowest_part_list_y(H264Context *h, Picture *pic, int n, int height, int y_offset, int list) { int raw_my = h->mv_cache[list][scan8[n]][1]; - int filter_height = (raw_my & 3) ? 2 : 0; + int filter_height_up = (raw_my & 3) ? 2 : 0; + int filter_height_down = (raw_my & 3) ? 3 : 0; int full_my = (raw_my >> 2) + y_offset; - int top = full_my - filter_height; - int bottom = full_my + filter_height + height; + int top = full_my - filter_height_up; + int bottom = full_my + filter_height_down + height; return FFMAX(abs(top), bottom); } @@ -1465,7 +1466,13 @@ static void decode_postinit(H264Context *h, int setup_finished) if( cur->f.pict_type == AV_PICTURE_TYPE_B || (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2)) out_of_order = FFMAX(out_of_order, 1); - if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){ + if (out_of_order == MAX_DELAYED_PIC_COUNT) { + av_log(s->avctx, AV_LOG_VERBOSE, "Invalid POC %d<%d\n", cur->poc, h->last_pocs[0]); + for (i = 1; i < MAX_DELAYED_PIC_COUNT; i++) + h->last_pocs[i] = INT_MIN; + h->last_pocs[0] = cur->poc; + cur->mmco_reset = 1; + } else if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){ av_log(s->avctx, AV_LOG_VERBOSE, "Increasing reorder buffer to %d\n", out_of_order); s->avctx->has_b_frames = out_of_order; s->low_delay = 0; @@ -2279,7 +2286,7 @@ static int field_end(H264Context *h, int in_setup) * past end by one (callers fault) and resync_mb_y != 0 * causes problems for the first MB line, too. */ - if (!FIELD_PICTURE) + if (!FIELD_PICTURE && h->current_slice) ff_er_frame_end(s); ff_MPV_frame_end(s); @@ -2359,7 +2366,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) MpegEncContext *const s0 = &h0->s; unsigned int first_mb_in_slice; unsigned int pps_id; - int num_ref_idx_active_override_flag; + int num_ref_idx_active_override_flag, ret; unsigned int slice_type, tmp, i, j; int default_ref_list_done = 0; int last_pic_structure, last_pic_dropable; @@ -2669,7 +2676,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) h->mb_mbaff = 0; h->mb_aff_frame = 0; last_pic_structure = s0->picture_structure; - last_pic_dropable = s->dropable; + last_pic_dropable = s0->dropable; s->dropable = h->nal_ref_idc == 0; if (h->sps.frame_mbs_only_flag) { s->picture_structure = PICT_FRAME; @@ -2787,6 +2794,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0) Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL; av_log(h->s.avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num); + if (!h->sps.gaps_in_frame_num_allowed_flag) + for(i=0; ilast_pocs); i++) + h->last_pocs[i] = INT_MIN; if (ff_h264_frame_start(h) < 0) return -1; h->prev_frame_num++; @@ -2794,7 +2804,9 @@ static int decode_slice_header(H264Context *h, H264Context *h0) s->current_picture_ptr->frame_num = h->prev_frame_num; ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0); ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 1); - ff_generate_sliding_window_mmcos(h); + if ((ret = ff_generate_sliding_window_mmcos(h, 1)) < 0 && + s->avctx->err_recognition & AV_EF_EXPLODE) + return ret; if (ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index) < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; @@ -2922,7 +2934,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0) h->ref_count[1] = get_ue_golomb(&s->gb) + 1; else // full range is spec-ok in this case, even for frames - max[1] = 31; + h->ref_count[1] = 1; } if (h->ref_count[0]-1 > max[0] || h->ref_count[1]-1 > max[1]){ @@ -2971,7 +2983,15 @@ static int decode_slice_header(H264Context *h, H264Context *h0) } } - if (h->nal_ref_idc && ff_h264_decode_ref_pic_marking(h0, &s->gb) < 0 && + // If frame-mt is enabled, only update mmco tables for the first slice + // in a field. Subsequent slices can temporarily clobber h->mmco_index + // or h->mmco, which will cause ref list mix-ups and decoding errors + // further down the line. This may break decoding if the first slice is + // corrupt, thus we only do this if frame-mt is enabled. + if (h->nal_ref_idc && + ff_h264_decode_ref_pic_marking(h0, &s->gb, + !(s->avctx->active_thread_type & FF_THREAD_FRAME) || + h0->current_slice == 0) < 0 && (s->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 4d07a8ac4d..65d1fd8c15 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -668,9 +668,10 @@ void ff_h264_remove_all_refs(H264Context *h); */ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count); -int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb); +int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb, + int first_slice); -void ff_generate_sliding_window_mmcos(H264Context *h); +int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice); /** * Check if the top & left blocks are available if needed & change the diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index f5d403b762..77ea194ccd 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -708,7 +708,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h){ down the code */ if(h->slice_type_nos != AV_PICTURE_TYPE_I){ if(s->mb_skip_run==-1) - s->mb_skip_run= get_ue_golomb(&s->gb); + s->mb_skip_run= get_ue_golomb_long(&s->gb); if (s->mb_skip_run--) { if(FRAME_MBAFF && (s->mb_y&1) == 0){ diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 2dea93301a..f9c3621d3f 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -154,7 +154,7 @@ pps: goto fail; /* prepend only to the first type 5 NAL unit of an IDR picture */ - if (ctx->first_idr && unit_type == 5) { + if (ctx->first_idr && (unit_type == 5 || unit_type == 7 || unit_type == 8)) { if ((ret=alloc_and_copy(poutbuf, poutbuf_size, avctx->extradata, avctx->extradata_size, buf, nal_size)) < 0) diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index cdc6b079b6..8df7f70265 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -367,7 +367,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ if(sps->profile_idc == 100 || sps->profile_idc == 110 || sps->profile_idc == 122 || sps->profile_idc == 244 || sps->profile_idc == 44 || sps->profile_idc == 83 || sps->profile_idc == 86 || sps->profile_idc == 118 || - sps->profile_idc == 128 ) { + sps->profile_idc == 128 || sps->profile_idc == 144) { sps->chroma_format_idc= get_ue_golomb_31(&s->gb); if (sps->chroma_format_idc > 3U) { av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc %d is illegal\n", sps->chroma_format_idc); @@ -381,7 +381,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ } sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8; sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8; - if (sps->bit_depth_luma > 14U || sps->bit_depth_chroma > 14U) { + if (sps->bit_depth_luma > 14U || sps->bit_depth_chroma > 14U || sps->bit_depth_luma != sps->bit_depth_chroma) { av_log(h->s.avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n", sps->bit_depth_luma, sps->bit_depth_chroma); goto fail; diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c index d68a7d8b0f..7c73cd9eaf 100644 --- a/libavcodec/h264_refs.c +++ b/libavcodec/h264_refs.c @@ -287,7 +287,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ for(list=0; listlist_count; list++){ for(index= 0; index < h->ref_count[list]; index++){ if (!h->ref_list[list][index].f.data[0]) { - av_log(h->s.avctx, AV_LOG_ERROR, "Missing reference picture\n"); + int i; + av_log(h->s.avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc); + for (i=0; ilast_pocs); i++) + h->last_pocs[i] = INT_MIN; if (h->default_ref_list[list][0].f.data[0]) h->ref_list[list][index]= h->default_ref_list[list][0]; else @@ -480,22 +483,53 @@ static void print_long_term(H264Context *h) { } } -void ff_generate_sliding_window_mmcos(H264Context *h) { - MpegEncContext * const s = &h->s; +static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos) +{ + int i; - h->mmco_index= 0; - if(h->short_ref_count && h->long_ref_count + h->short_ref_count >= h->sps.ref_frame_count && - !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->f.reference)) { - h->mmco[0].opcode= MMCO_SHORT2UNUSED; - h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; - h->mmco_index= 1; - if (FIELD_PICTURE) { - h->mmco[0].short_pic_num *= 2; - h->mmco[1].opcode= MMCO_SHORT2UNUSED; - h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1; - h->mmco_index= 2; + for (i = 0; i < n_mmcos; i++) { + if (mmco1[i].opcode != mmco2[i].opcode) { + av_log(NULL, AV_LOG_ERROR, "MMCO opcode [%d, %d] at %d mismatches between slices\n", + mmco1[i].opcode, mmco2[i].opcode, i); + return -1; } } + + return 0; +} + +int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice) +{ + MpegEncContext * const s = &h->s; + MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp; + int mmco_index = 0, i; + + if (h->short_ref_count && + h->long_ref_count + h->short_ref_count >= h->sps.ref_frame_count && + !(FIELD_PICTURE && !s->first_field && + s->current_picture_ptr->f.reference)) { + mmco[0].opcode = MMCO_SHORT2UNUSED; + mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num; + mmco_index = 1; + if (FIELD_PICTURE) { + mmco[0].short_pic_num *= 2; + mmco[1].opcode = MMCO_SHORT2UNUSED; + mmco[1].short_pic_num = mmco[0].short_pic_num + 1; + mmco_index = 2; + } + } + + if (first_slice) { + h->mmco_index = mmco_index; + } else if (!first_slice && mmco_index >= 0 && + (mmco_index != h->mmco_index || + (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) { + av_log(h->s.avctx, AV_LOG_ERROR, + "Inconsistent MMCO state between slices [%d, %d]\n", + mmco_index, h->mmco_index); + return AVERROR_INVALIDDATA; + } + return 0; } int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ @@ -519,7 +553,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ if(!pic){ if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg] || h->long_ref[mmco[i].long_arg]->frame_num != frame_num) { - av_log(h->s.avctx, AV_LOG_ERROR, "mmco: unref short failure\n"); + av_log(h->s.avctx, h->short_ref_count ? AV_LOG_ERROR : AV_LOG_DEBUG, "mmco: unref short failure\n"); err = AVERROR_INVALIDDATA; } continue; @@ -656,7 +690,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ print_short_term(h); print_long_term(h); - if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){ + if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=2 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){ s->current_picture_ptr->sync |= 1; if(!h->s.avctx->has_b_frames) h->sync = 2; @@ -665,52 +699,86 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ return (h->s.avctx->err_recognition & AV_EF_EXPLODE) ? err : 0; } -int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){ +int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb, + int first_slice) +{ MpegEncContext * const s = &h->s; - int i; + int i, ret; + MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp; + int mmco_index = 0; - h->mmco_index= 0; - if(h->nal_unit_type == NAL_IDR_SLICE){ //FIXME fields - s->broken_link= get_bits1(gb) -1; - if(get_bits1(gb)){ - h->mmco[0].opcode= MMCO_LONG; - h->mmco[0].long_arg= 0; - h->mmco_index= 1; + if (h->nal_unit_type == NAL_IDR_SLICE){ // FIXME fields + s->broken_link = get_bits1(gb) - 1; + if (get_bits1(gb)){ + mmco[0].opcode = MMCO_LONG; + mmco[0].long_arg = 0; + mmco_index = 1; } - }else{ - if(get_bits1(gb)){ // adaptive_ref_pic_marking_mode_flag - for(i= 0; immco[i].opcode= opcode; - if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){ - h->mmco[i].short_pic_num= (h->curr_pic_num - get_ue_golomb(gb) - 1) & (h->max_pic_num - 1); -/* if(h->mmco[i].short_pic_num >= h->short_ref_count || h->short_ref[ h->mmco[i].short_pic_num ] == NULL){ - av_log(s->avctx, AV_LOG_ERROR, "illegal short ref in memory management control operation %d\n", mmco); - return -1; - }*/ - } - if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ - unsigned int long_arg= get_ue_golomb_31(gb); - if(long_arg >= 32 || (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG && long_arg == 16) && !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){ - av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode); + mmco[i].opcode = opcode; + if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG){ + mmco[i].short_pic_num = + (h->curr_pic_num - get_ue_golomb(gb) - 1) & + (h->max_pic_num - 1); +#if 0 + if (mmco[i].short_pic_num >= h->short_ref_count || + h->short_ref[ mmco[i].short_pic_num ] == NULL){ + av_log(s->avctx, AV_LOG_ERROR, + "illegal short ref in memory management control " + "operation %d\n", mmco); return -1; } - h->mmco[i].long_arg= long_arg; +#endif + } + if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED || + opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) { + unsigned int long_arg = get_ue_golomb_31(gb); + if (long_arg >= 32 || + (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG && + long_arg == 16) && + !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){ + av_log(h->s.avctx, AV_LOG_ERROR, + "illegal long ref in memory management control " + "operation %d\n", opcode); + return -1; + } + mmco[i].long_arg = long_arg; } - if(opcode > (unsigned)MMCO_LONG){ - av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); + if (opcode > (unsigned) MMCO_LONG){ + av_log(h->s.avctx, AV_LOG_ERROR, + "illegal memory management control operation %d\n", + opcode); return -1; } - if(opcode == MMCO_END) + if (opcode == MMCO_END) break; } - h->mmco_index= i; - }else{ - ff_generate_sliding_window_mmcos(h); + mmco_index = i; + } else { + if (first_slice) { + ret = ff_generate_sliding_window_mmcos(h, first_slice); + if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE) + return ret; + } + mmco_index = -1; } } + if (first_slice && mmco_index != -1) { + h->mmco_index = mmco_index; + } else if (!first_slice && mmco_index >= 0 && + (mmco_index != h->mmco_index || + (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) { + av_log(h->s.avctx, AV_LOG_ERROR, + "Inconsistent MMCO state between slices [%d, %d]\n", + mmco_index, h->mmco_index); + return AVERROR_INVALIDDATA; + } + return 0; } diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 2a9ebe1b2c..72ed3515bb 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -267,12 +267,13 @@ static void generate_joint_tables(HYuvContext *s) for (i = y = 0; y < 256; y++) { int len0 = s->len[0][y]; int limit = VLC_BITS - len0; - if(limit <= 0) + if(limit <= 0 || !len0) continue; for (u = 0; u < 256; u++) { int len1 = s->len[p][u]; - if (len1 > limit) + if (len1 > limit || !len1) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1; bits[i] = (s->bits[0][y] << len1) + s->bits[p][u]; symbols[i] = (y << 8) + u; @@ -295,18 +296,19 @@ static void generate_joint_tables(HYuvContext *s) for (i = 0, g = -16; g < 16; g++) { int len0 = s->len[p0][g & 255]; int limit0 = VLC_BITS - len0; - if (limit0 < 2) + if (limit0 < 2 || !len0) continue; for (b = -16; b < 16; b++) { int len1 = s->len[p1][b & 255]; int limit1 = limit0 - len1; - if (limit1 < 1) + if (limit1 < 1 || !len1) continue; code = (s->bits[p0][g & 255] << len1) + s->bits[p1][b & 255]; for (r = -16; r < 16; r++) { int len2 = s->len[2][r & 255]; - if (len2 > limit1) + if (len2 > limit1 || !len2) continue; + av_assert0(i < (1 << VLC_BITS)); len[i] = len0 + len1 + len2; bits[i] = (code << len2) + s->bits[2][r & 255]; if (s->decorrelate) { @@ -331,6 +333,7 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, src, length * 8); @@ -341,8 +344,9 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length) return -1; } ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); @@ -354,6 +358,7 @@ static int read_old_huffman_tables(HYuvContext *s) { GetBitContext gb; int i; + int ret; init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size * 8); @@ -377,8 +382,9 @@ static int read_old_huffman_tables(HYuvContext *s) for (i = 0; i < 3; i++) { ff_free_vlc(&s->vlc[i]); - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, - s->bits[i], 4, 4, 0); + if ((ret = init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, + s->bits[i], 4, 4, 0)) < 0) + return ret; } generate_joint_tables(s); @@ -514,7 +520,10 @@ static av_cold int decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "width must be even for this colorspace\n"); return AVERROR_INVALIDDATA; } - + if (s->predictor == MEDIAN && avctx->pix_fmt == PIX_FMT_YUV422P && avctx->width%4) { + av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 4 this colorspace and predictor\n"); + return AVERROR_INVALIDDATA; + } alloc_temp(s); return 0; diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 2c4ea8f8e6..08360d5c18 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -562,13 +562,13 @@ static int decode_frame_ilbm(AVCodecContext *avctx, } } else if (avctx->codec_tag == MKTAG('P','B','M',' ')) { // IFF-PBM if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) { - for(y = 0; y < avctx->height; y++ ) { + for(y = 0; y < avctx->height && buf_end > buf; y++ ) { uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]]; memcpy(row, buf, FFMIN(avctx->width, buf_end - buf)); buf += avctx->width + (avctx->width % 2); // padding if odd } } else if (s->ham) { // IFF-PBM: HAM to PIX_FMT_BGR32 - for (y = 0; y < avctx->height; y++) { + for (y = 0; y < avctx->height && buf_end > buf; y++) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memcpy(s->ham_buf, buf, FFMIN(avctx->width, buf_end - buf)); buf += avctx->width + (avctx->width & 1); // padding if odd diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c index b3ba8fc0c9..d1de0b9810 100644 --- a/libavcodec/j2kdec.c +++ b/libavcodec/j2kdec.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "bytestream.h" #include "j2k.h" +#include "libavutil/avassert.h" #include "libavutil/common.h" #define JP2_SIG_TYPE 0x6A502020 @@ -298,6 +299,10 @@ static int get_cox(J2kDecoderContext *s, J2kCodingStyle *c) c->log2_cblk_width = bytestream2_get_byteu(&s->g) + 2; // cblk width c->log2_cblk_height = bytestream2_get_byteu(&s->g) + 2; // cblk height + if (c->log2_cblk_width > 6 || c->log2_cblk_height > 6) { + return AVERROR_PATCHWELCOME; + } + c->cblk_style = bytestream2_get_byteu(&s->g); if (c->cblk_style != 0){ // cblk style av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", c->cblk_style); @@ -715,6 +720,9 @@ static int decode_cblk(J2kDecoderContext *s, J2kCodingStyle *codsty, J2kT1Contex int bpass_csty_symbol = J2K_CBLK_BYPASS & codsty->cblk_style; int vert_causal_ctx_csty_symbol = J2K_CBLK_VSC & codsty->cblk_style; + av_assert0(width <= J2K_MAX_CBLKW); + av_assert0(height <= J2K_MAX_CBLKH); + for (y = 0; y < height+2; y++) memset(t1->flags[y], 0, (width+2)*sizeof(int)); diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 879922a0e0..417bb4068d 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -142,6 +142,8 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RI ret = ret >> 1; } + if(FFABS(ret) > 0xFFFF) + return -0x10000; /* update state */ state->A[Q] += FFABS(ret) - RItype; ret *= state->twonear; diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index cde410e5e1..3cdae68f39 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -106,7 +106,7 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, int w, int h) val = bytestream2_get_byte(&ctx->g); mx = val & 0xF; my = val >> 4; - if ((l0x-mx) + 320*(l0y-my) < 0 || (l0x-mx) + 320*(l0y-my) > 316*196) { + if ((l0x-mx) + 320*(l0y-my) < 0 || (l0x-mx) + 320*(l0y-my) > 320*197 - 4) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n"); return AVERROR_INVALIDDATA; } @@ -131,7 +131,7 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, int w, int h) val = bytestream2_get_byte(&ctx->g); mx = val & 0xF; my = val >> 4; - if ((l1x-mx) + 320*(l1y-my) < 0 || (l1x-mx) + 320*(l1y-my) > 318*198) { + if ((l1x-mx) + 320*(l1y-my) < 0 || (l1x-mx) + 320*(l1y-my) > 320*199 - 2) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n"); return AVERROR_INVALIDDATA; } @@ -206,7 +206,7 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, int w, int h) val = bytestream2_get_byte(&ctx->g); mx = (val & 0xF) - 8; my = (val >> 4) - 8; - if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 318*198) { + if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 320*197 - 4) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n"); return AVERROR_INVALIDDATA; } @@ -231,7 +231,7 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, int w, int h) val = bytestream2_get_byte(&ctx->g); mx = (val & 0xF) - 8; my = (val >> 4) - 8; - if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 318*198) { + if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 320*199 - 2) { av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n"); return AVERROR_INVALIDDATA; } diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index f180373eae..2a4d61d180 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -41,6 +41,7 @@ #include #include +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "bytestream.h" #include "lcl.h" @@ -484,6 +485,7 @@ static av_cold int decode_init(AVCodecContext *avctx) unsigned int basesize = avctx->width * avctx->height; unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) + AV_LZO_OUTPUT_PADDING; unsigned int max_decomp_size; + int subsample_h, subsample_v; avcodec_get_frame_defaults(&c->pic); if (avctx->extradata_size < 8) { @@ -510,6 +512,10 @@ static av_cold int decode_init(AVCodecContext *avctx) max_decomp_size = max_basesize * 2; avctx->pix_fmt = PIX_FMT_YUV422P; av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:2:2.\n"); + if (avctx->width % 4) { + av_log_ask_for_sample(avctx, "Unsupported dimensions\n"); + return AVERROR_INVALIDDATA; + } break; case IMGTYPE_RGB24: c->decomp_size = basesize * 3; @@ -540,6 +546,12 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } + avcodec_get_chroma_sub_sample(avctx->pix_fmt, &subsample_h, &subsample_v); + if (avctx->width % (1<height % (1<compression = (int8_t)avctx->extradata[5]; switch (avctx->codec_id) { diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c index 0bfed1e0fc..685d14476f 100644 --- a/libavcodec/libfaac.c +++ b/libavcodec/libfaac.c @@ -201,7 +201,7 @@ static int Faac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, /* add current frame to the queue */ if (frame) { - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index 2874e3797c..03744266f1 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -334,7 +334,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, in_buf.bufElSizes = &in_buffer_element_size; /* add current frame to the queue */ - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 427cacdf8e..55657e4be2 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -234,7 +234,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, /* add current frame to the queue */ if (frame) { - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index aa6dfa62ec..9a096f3d09 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -258,7 +258,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (frame->nb_samples < avctx->frame_size - avctx->delay) s->enc_last_frame = -1; } - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) { + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) { av_freep(&flush_buf); return ret; } diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index cd32630a01..50d8607a47 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -254,7 +254,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, speex_encode_stereo_int(samples, s->header.frame_size, &s->bits); speex_encode_int(s->enc_state, samples, &s->bits); s->pkt_frame_count++; - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } else { /* handle end-of-stream */ diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index 3b7aca7386..531b40d24e 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -157,7 +157,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, samples = (VO_PBYTE)frame->data[0]; } /* add current frame to the queue */ - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index 76a912d439..8f93288ba4 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -307,7 +307,7 @@ static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n"); return vorbis_error_to_averror(ret); } - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } else { if (!s->eof) @@ -362,7 +362,10 @@ static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, * libvorbis, so we have to update the AudioFrameQueue counts */ if (!avctx->delay) { avctx->delay = duration; - s->afq.remaining_delay += duration; + av_assert0(!s->afq.remaining_delay); + s->afq.frames->duration += duration; + if (s->afq.frames->pts != AV_NOPTS_VALUE) + s->afq.frames->pts -= duration; s->afq.remaining_samples += duration; } ff_af_queue_remove(&s->afq, duration, &avpkt->pts, &avpkt->duration); diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index a2d64d1977..691f5d2c78 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -174,7 +174,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, frame->pict_type == AV_PICTURE_TYPE_P ? X264_TYPE_P : frame->pict_type == AV_PICTURE_TYPE_B ? X264_TYPE_B : X264_TYPE_AUTO; - if (x4->params.b_tff != frame->top_field_first) { + if (x4->params.b_interlaced && x4->params.b_tff != frame->top_field_first) { x4->params.b_tff = frame->top_field_first; x264_encoder_reconfig(x4->enc, &x4->params); } diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index d829b1b53f..02ad11806d 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -718,6 +718,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p int resync_mb_y = 0; int resync_mb_x = 0; + if (s->nb_components != 3 && s->nb_components != 4) + return AVERROR_INVALIDDATA; + if (s->v_max != 1 || s->h_max != 1 || !s->lossless) + return AVERROR_INVALIDDATA; + + s->restart_count = s->restart_interval; av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size, @@ -1097,8 +1103,13 @@ static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int last_scan = 0; int16_t *quant_matrix = s->quant_matrixes[s->quant_index[c]]; + if (se > 63) { + av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se); + return AVERROR_INVALIDDATA; + } + if (!Al) { - s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss); + s->coefs_finished[c] |= (2LL << se) - (1LL << ss); last_scan = !~s->coefs_finished[c]; } @@ -1597,6 +1608,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size, MJpegDecodeContext *s = avctx->priv_data; const uint8_t *buf_end, *buf_ptr; const uint8_t *unescaped_buf_ptr; + int hshift, vshift; int unescaped_buf_size; int start_code; int i, index; @@ -1774,6 +1786,9 @@ the_end: } if (s->upscale_v) { uint8_t *dst = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(s->height - 1) * s->linesize[s->upscale_v]]; + int w; + avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift); + w = s->width >> hshift; av_assert0(avctx->pix_fmt == PIX_FMT_YUVJ444P || avctx->pix_fmt == PIX_FMT_YUV444P || avctx->pix_fmt == PIX_FMT_YUVJ422P || @@ -1782,16 +1797,16 @@ the_end: uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[i / 2 * s->linesize[s->upscale_v]]; uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(i + 1) / 2 * s->linesize[s->upscale_v]]; if (src1 == src2) { - memcpy(dst, src1, s->width); + memcpy(dst, src1, w); } else { - for (index = 0; index < s->width; index++) + for (index = 0; index < w; index++) dst[index] = (src1[index] + src2[index]) >> 1; } dst -= s->linesize[s->upscale_v]; } } if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) { - int hshift, vshift, j; + int j; avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift); for (index=0; index<4; index++) { uint8_t *dst = s->picture_ptr->data[index]; diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index ff8908a7b6..40892a7c4c 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -104,6 +104,9 @@ static int mm_decode_intra(MmContext * s, int half_horiz, int half_vert) if (half_horiz) run_length *=2; + if (run_length > s->avctx->width - x) + return AVERROR_INVALIDDATA; + if (color) { memset(s->frame.data[0] + y*s->frame.linesize[0] + x, color, run_length); if (half_vert) @@ -151,6 +154,8 @@ static int mm_decode_inter(MmContext * s, int half_horiz, int half_vert) int replace_array = bytestream2_get_byte(&s->gb); for(j=0; j<8; j++) { int replace = (replace_array >> (7-j)) & 1; + if (x + half_horiz >= s->avctx->width) + return AVERROR_INVALIDDATA; if (replace) { int color = bytestream2_get_byte(&data_ptr); s->frame.data[0][y*s->frame.linesize[0] + x] = color; diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index a65bbb83e3..05ff53afb4 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -83,7 +83,7 @@ static int mov_text_decode_frame(AVCodecContext *avctx, * In complex cases, there are style descriptors appended to the string * so we can't just assume the packet size is the string size. */ - end = ptr + FFMAX(2 + AV_RB16(ptr), avpkt->size); + end = ptr + FFMIN(2 + AV_RB16(ptr), avpkt->size); ptr += 2; ts_start = av_rescale_q(avpkt->pts, diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 7f1b5b830f..9b0a6c5bce 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -21,6 +21,7 @@ #include #include "avcodec.h" +#include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "ass_split.h" @@ -87,15 +88,18 @@ static av_cold int mov_text_encode_init(AVCodecContext *avctx) static void mov_text_text_cb(void *priv, const char *text, int len) { MovTextContext *s = priv; + av_assert0(s->end >= s->ptr); av_strlcpy(s->ptr, text, FFMIN(s->end - s->ptr, len + 1)); - s->ptr += len; + s->ptr += FFMIN(s->end - s->ptr, len); } static void mov_text_new_line_cb(void *priv, int forced) { MovTextContext *s = priv; + av_assert0(s->end >= s->ptr); av_strlcpy(s->ptr, "\n", FFMIN(s->end - s->ptr, 2)); - s->ptr++; + if (s->end > s->ptr) + s->ptr++; } static const ASSCodesCallbacks mov_text_callbacks = { diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 1e7ff9cf6f..07c5016682 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -1263,7 +1263,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) s1->save_width != s->width || s1->save_height != s->height || s1->save_aspect_info != s->aspect_ratio_info || - s1->save_progressive_seq != s->progressive_sequence || + (s1->save_progressive_seq != s->progressive_sequence && (s->height&31)) || 0) { @@ -1989,8 +1989,6 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, width = get_bits(&s->gb, 12); height = get_bits(&s->gb, 12); - if (width <= 0 || height <= 0) - return -1; s->aspect_ratio_info = get_bits(&s->gb, 4); if (s->aspect_ratio_info == 0) { av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n"); @@ -2356,6 +2354,11 @@ static int decode_chunks(AVCodecContext *avctx, break; case PICTURE_START_CODE: + if (s2->width <= 0 || s2->height <= 0) { + av_log(avctx, AV_LOG_ERROR, "%dx%d is invalid\n", s2->width, s2->height); + return AVERROR_INVALIDDATA; + } + if(s->tmpgexs){ s2->intra_dc_precision= 3; s2->intra_matrix[0]= 1; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 5afa944cdb..d4606a98cb 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -132,6 +132,9 @@ static av_cold int encode_init(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; + if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && avctx->height > 2800) + avctx->thread_count = 1; + if(ff_MPV_encode_init(avctx) < 0) return -1; @@ -167,6 +170,19 @@ static av_cold int encode_init(AVCodecContext *avctx) } } + if ((avctx->width & 0xFFF) == 0 && (avctx->height & 0xFFF) == 1) { + av_log(avctx, AV_LOG_ERROR, "Width / Height is invalid for MPEG2\n"); + return AVERROR(EINVAL); + } + + if (s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { + if ((avctx->width & 0xFFF) == 0 || (avctx->height & 0xFFF) == 0) { + av_log(avctx, AV_LOG_ERROR, "Width or Height are not allowed to be multiplies of 4096\n" + "add '-strict %d' if you want to use them anyway.\n", FF_COMPLIANCE_UNOFFICIAL); + return AVERROR(EINVAL); + } + } + s->drop_frame_timecode = s->drop_frame_timecode || !!(avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE); if (s->drop_frame_timecode) s->tc.flags |= AV_TIMECODE_FLAG_DROPFRAME; @@ -214,8 +230,8 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) /* mpeg1 header repeated every gop */ put_header(s, SEQ_START_CODE); - put_sbits(&s->pb, 12, s->width ); - put_sbits(&s->pb, 12, s->height); + put_sbits(&s->pb, 12, s->width & 0xFFF); + put_sbits(&s->pb, 12, s->height & 0xFFF); for(i=1; i<15; i++){ float error= aspect_ratio; @@ -459,7 +475,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s, } if (cbp == 0 && !first_mb && s->mv_type == MV_TYPE_16X16 && - (mb_x != s->mb_width - 1 || (mb_y != s->mb_height - 1 && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)) && + (mb_x != s->mb_width - 1 || (mb_y != s->end_mb_y - 1 && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)) && ((s->pict_type == AV_PICTURE_TYPE_P && (motion_x | motion_y) == 0) || (s->pict_type == AV_PICTURE_TYPE_B && s->mv_dir == s->last_mv_dir && (((s->mv_dir & MV_DIR_FORWARD) ? ((s->mv[0][0][0] - s->last_mv[0][0][0])|(s->mv[0][0][1] - s->last_mv[0][0][1])) : 0) | ((s->mv_dir & MV_DIR_BACKWARD) ? ((s->mv[1][0][0] - s->last_mv[1][0][0])|(s->mv[1][0][1] - s->last_mv[1][0][1])) : 0)) == 0))) { @@ -972,7 +988,7 @@ AVCodec ff_mpeg1video_encoder = { .supported_framerates = avpriv_frame_rate_tab+1, .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV420P, PIX_FMT_NONE }, - .capabilities = CODEC_CAP_DELAY, + .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"), .priv_class = &mpeg1_class, }; diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 5f97d711c6..bb4d75c066 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -30,6 +30,7 @@ typedef struct MpegAudioParseContext { int frame_size; uint32_t header; int header_count; + int no_bitrate; } MpegAudioParseContext; #define MPA_HEADER_SIZE 4 @@ -74,15 +75,18 @@ static int mpegaudio_parse(AVCodecParserContext *s1, if((state&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header) s->header_count= -3; s->header= state; - s->header_count++; s->frame_size = ret-4; - if (s->header_count > 1) { + if (s->header_count > 0) { avctx->sample_rate= sr; avctx->channels = channels; s1->duration = frame_size; - avctx->bit_rate = bit_rate; + if (s->no_bitrate || !avctx->bit_rate) { + s->no_bitrate = 1; + avctx->bit_rate += (bit_rate - avctx->bit_rate) / s->header_count; + } } + s->header_count++; break; } } diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 9e1f67c016..d5e018af1a 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -2085,7 +2085,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x; ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x; - if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || + if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 || (unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17 + field_based, @@ -2125,11 +2125,12 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy); if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) { + int hc = s->chroma_y_shift ? (h+1-bottom_field)>>1 : h; uvsx = (uvsx << 2) >> lowres; uvsy = (uvsy << 2) >> lowres; - if (h >> s->chroma_y_shift) { - pix_op[op_index](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); - pix_op[op_index](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy); + if (hc) { + pix_op[op_index](dest_cb, ptr_cb, uvlinesize, hc, uvsx, uvsy); + pix_op[op_index](dest_cr, ptr_cr, uvlinesize, hc, uvsx, uvsy); } } // FIXME h261 lowres loop filter diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4322d65e73..7d7672b7c4 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -402,6 +402,32 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) s->loop_filter = !!(s->flags & CODEC_FLAG_LOOP_FILTER); + if (avctx->rc_max_rate && !avctx->rc_buffer_size) { + switch(avctx->codec_id) { + case AV_CODEC_ID_MPEG1VIDEO: + case AV_CODEC_ID_MPEG2VIDEO: + avctx->rc_buffer_size = FFMAX(avctx->rc_max_rate, 15000000) * 112L / 15000000 * 16384; + break; + case AV_CODEC_ID_MPEG4: + case AV_CODEC_ID_MSMPEG4V1: + case AV_CODEC_ID_MSMPEG4V2: + case AV_CODEC_ID_MSMPEG4V3: + if (avctx->rc_max_rate >= 15000000) { + avctx->rc_buffer_size = 320 + (avctx->rc_max_rate - 15000000L) * (760-320) / (38400000 - 15000000); + } else if(avctx->rc_max_rate >= 2000000) { + avctx->rc_buffer_size = 80 + (avctx->rc_max_rate - 2000000L) * (320- 80) / (15000000 - 2000000); + } else if(avctx->rc_max_rate >= 384000) { + avctx->rc_buffer_size = 40 + (avctx->rc_max_rate - 384000L) * ( 80- 40) / ( 2000000 - 384000); + } else + avctx->rc_buffer_size = 40; + avctx->rc_buffer_size *= 16384; + break; + } + if (avctx->rc_buffer_size) { + av_log(avctx, AV_LOG_INFO, "Automatically choosing VBV buffer size of %d kbyte\n", avctx->rc_buffer_size/8192); + } + } + if ((!avctx->rc_max_rate) != (!avctx->rc_buffer_size)) { av_log(avctx, AV_LOG_ERROR, "Either both buffer size and max rate or neither must be specified\n"); if (avctx->rc_max_rate && !avctx->rc_buffer_size) @@ -606,7 +632,7 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) return -1; } - if (s->avctx->thread_count > 1) + if (s->avctx->slices > 1 || s->avctx->thread_count > 1) s->rtp_mode = 1; if (s->avctx->thread_count > 1 && s->codec_id == AV_CODEC_ID_H263P) diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index 7c965d25e2..4f2d753550 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -35,6 +35,7 @@ #include "avcodec.h" #include "dsputil.h" #include "msrledec.h" +#include "libavutil/imgutils.h" typedef struct MsrleContext { AVCodecContext *avctx; @@ -112,7 +113,7 @@ static int msrle_decode_frame(AVCodecContext *avctx, /* FIXME how to correctly detect RLE ??? */ if (avctx->height * istride == avpkt->size) { /* assume uncompressed */ - int linesize = (avctx->width * avctx->bits_per_coded_sample + 7) / 8; + int linesize = av_image_get_linesize(avctx->pix_fmt, avctx->width, 0); uint8_t *ptr = s->frame.data[0]; uint8_t *buf = avpkt->data + (avctx->height-1)*istride; int i, j; diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c index 36a46b5978..b0b8ef1c7f 100644 --- a/libavcodec/msrledec.c +++ b/libavcodec/msrledec.c @@ -138,7 +138,8 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, unsigned int width= FFABS(pic->linesize[0]) / (depth >> 3); output = pic->data[0] + (avctx->height - 1) * pic->linesize[0]; - output_end = pic->data[0] + avctx->height * pic->linesize[0]; + output_end = output + FFABS(pic->linesize[0]); + while (bytestream2_get_bytes_left(gb) > 0) { p1 = bytestream2_get_byteu(gb); if(p1 == 0) { //Escape code @@ -155,6 +156,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, return AVERROR_INVALIDDATA; } } + output_end = output + FFABS(pic->linesize[0]); pos = 0; continue; } else if(p2 == 1) { //End-of-picture @@ -169,11 +171,11 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, return -1; } output = pic->data[0] + line * pic->linesize[0] + pos * (depth >> 3); + output_end = pic->data[0] + line * pic->linesize[0] + FFABS(pic->linesize[0]); continue; } // Copy data - if ((pic->linesize[0] > 0 && output + p2 * (depth >> 3) > output_end) || - (pic->linesize[0] < 0 && output + p2 * (depth >> 3) < output_end)) { + if (output + p2 * (depth >> 3) > output_end) { bytestream2_skip(gb, 2 * (depth >> 3)); continue; } else if (bytestream2_get_bytes_left(gb) < p2 * (depth >> 3)) { @@ -203,36 +205,39 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, pos += p2; } else { //run of pixels uint8_t pix[3]; //original pixel - switch(depth){ - case 8: pix[0] = bytestream2_get_byte(gb); - break; - case 16: pix16 = bytestream2_get_le16(gb); - break; - case 24: pix[0] = bytestream2_get_byte(gb); - pix[1] = bytestream2_get_byte(gb); - pix[2] = bytestream2_get_byte(gb); - break; - case 32: pix32 = bytestream2_get_le32(gb); - break; - } - if ((pic->linesize[0] > 0 && output + p1 * (depth >> 3) > output_end) || - (pic->linesize[0] < 0 && output + p1 * (depth >> 3) < output_end)) + if (output + p1 * (depth >> 3) > output_end) continue; - for(i = 0; i < p1; i++) { - switch(depth){ - case 8: *output++ = pix[0]; - break; - case 16: *(uint16_t*)output = pix16; - output += 2; - break; - case 24: *output++ = pix[0]; - *output++ = pix[1]; - *output++ = pix[2]; - break; - case 32: *(uint32_t*)output = pix32; - output += 4; - break; + + switch(depth){ + case 8: + pix[0] = bytestream2_get_byte(gb); + for(i = 0; i < p1; i++) + *output++ = pix[0]; + break; + case 16: + pix16 = bytestream2_get_le16(gb); + for(i = 0; i < p1; i++) { + *(uint16_t*)output = pix16; + output += 2; } + break; + case 24: + pix[0] = bytestream2_get_byte(gb); + pix[1] = bytestream2_get_byte(gb); + pix[2] = bytestream2_get_byte(gb); + for(i = 0; i < p1; i++) { + *output++ = pix[0]; + *output++ = pix[1]; + *output++ = pix[2]; + } + break; + case 32: + pix32 = bytestream2_get_le32(gb); + for(i = 0; i < p1; i++) { + *(uint32_t*)output = pix32; + output += 4; + } + break; } pos += p1; } diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 2b96d47580..525ad8e1b0 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -397,7 +397,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (frame->nb_samples >= NELLY_BUF_LEN) s->last_frame = 1; } - if ((ret = ff_af_queue_add(&s->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } else { memset(s->buf + NELLY_BUF_LEN, 0, NELLY_SAMPLES * sizeof(*s->buf)); diff --git a/libavcodec/parser.c b/libavcodec/parser.c index df5ecb3b87..cf66e93ebb 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -244,8 +244,10 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s if(next == END_NOT_FOUND){ void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - if(!new_buffer) + if(!new_buffer) { + pc->index = 0; return AVERROR(ENOMEM); + } pc->buffer = new_buffer; memcpy(&pc->buffer[pc->index], *buf, *buf_size); pc->index += *buf_size; @@ -258,9 +260,11 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s /* append to buffer */ if(pc->index){ void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE); - - if(!new_buffer) + if(!new_buffer) { + pc->overread_index = + pc->index = 0; return AVERROR(ENOMEM); + } pc->buffer = new_buffer; memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); pc->index = 0; diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 728f178ebd..26a3c2a2f7 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -222,6 +222,11 @@ static int parse_picture_segment(AVCodecContext *avctx, return -1; } + if (buf_size > rle_bitmap_len) { + av_log(avctx, AV_LOG_ERROR, "too much RLE data\n"); + return AVERROR_INVALIDDATA; + } + ctx->pictures[picture_id].w = width; ctx->pictures[picture_id].h = height; diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index a5faeba42a..34557248b2 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -187,7 +187,7 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w if(bpp >= 2) g = dst[1];\ if(bpp >= 3) b = dst[2];\ if(bpp >= 4) a = dst[3];\ - for(; i < size; i+=bpp) {\ + for(; i <= size - bpp; i+=bpp) {\ dst[i+0] = r = op(r, src[i+0], last[i+0]);\ if(bpp == 1) continue;\ dst[i+1] = g = op(g, src[i+1], last[i+1]);\ @@ -203,13 +203,9 @@ void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w else if(bpp == 2) UNROLL1(2, op)\ else if(bpp == 3) UNROLL1(3, op)\ else if(bpp == 4) UNROLL1(4, op)\ - else {\ - for (; i < size; i += bpp) {\ - int j;\ - for (j = 0; j < bpp; j++)\ - dst[i+j] = op(dst[i+j-bpp], src[i+j], last[i+j]);\ - }\ - } + for (; i < size; i++) {\ + dst[i] = op(dst[i-bpp], src[i], last[i]);\ + }\ /* NOTE: 'dst' can be equal to 'last' */ static void png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, diff --git a/libavcodec/pngdsp.c b/libavcodec/pngdsp.c index 75ec996ca1..eb8c6b23eb 100644 --- a/libavcodec/pngdsp.c +++ b/libavcodec/pngdsp.c @@ -30,7 +30,7 @@ static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) { long i; - for (i = 0; i <= w - sizeof(long); i += sizeof(long)) { + for (i = 0; i <= w - (int)sizeof(long); i += sizeof(long)) { long a = *(long *)(src1 + i); long b = *(long *)(src2 + i); *(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80); diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 0d00a0866c..96511b3df3 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -244,12 +244,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, color_type = PNG_COLOR_TYPE_RGB; break; case PIX_FMT_RGBA: - avctx->bits_per_coded_sample = 32; bit_depth = 8; color_type = PNG_COLOR_TYPE_RGB_ALPHA; break; case PIX_FMT_RGB24: - avctx->bits_per_coded_sample = 24; bit_depth = 8; color_type = PNG_COLOR_TYPE_RGB; break; @@ -258,7 +256,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, color_type = PNG_COLOR_TYPE_GRAY; break; case PIX_FMT_GRAY8: - avctx->bits_per_coded_sample = 0x28; bit_depth = 8; color_type = PNG_COLOR_TYPE_GRAY; break; @@ -267,12 +264,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, color_type = PNG_COLOR_TYPE_GRAY_ALPHA; break; case PIX_FMT_MONOBLACK: - avctx->bits_per_coded_sample = bit_depth = 1; color_type = PNG_COLOR_TYPE_GRAY; break; case PIX_FMT_PAL8: - avctx->bits_per_coded_sample = bit_depth = 8; color_type = PNG_COLOR_TYPE_PALETTE; break; @@ -432,6 +427,23 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, static av_cold int png_enc_init(AVCodecContext *avctx){ PNGEncContext *s = avctx->priv_data; + switch(avctx->pix_fmt) { + case PIX_FMT_RGBA: + avctx->bits_per_coded_sample = 32; + break; + case PIX_FMT_RGB24: + avctx->bits_per_coded_sample = 24; + break; + case PIX_FMT_GRAY8: + avctx->bits_per_coded_sample = 0x28; + break; + case PIX_FMT_MONOBLACK: + avctx->bits_per_coded_sample = 1; + break; + case PIX_FMT_PAL8: + avctx->bits_per_coded_sample = 8; + } + avcodec_get_frame_defaults(&s->picture); avctx->coded_frame= &s->picture; ff_dsputil_init(&s->dsp, avctx); diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index a4a7cbb683..09dd83d315 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -106,7 +106,7 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av if (!cutoff_coeff && avctx->codec_id == AV_CODEC_ID_AAC) cutoff_coeff = 2.0 * AAC_CUTOFF(avctx) / avctx->sample_rate; - if (cutoff_coeff) + if (cutoff_coeff && cutoff_coeff < 0.98) ctx->fcoeffs = ff_iir_filter_init_coeffs(avctx, FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS, FILT_ORDER, cutoff_coeff, 0.0, 0.0); diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 3a77e7fe06..7f565dd3d7 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -1259,6 +1259,11 @@ static void qdm2_decode_super_block (QDM2Context *q) for (i = 0; packet_bytes > 0; i++) { int j; + if (i>=FF_ARRAY_ELEMS(q->sub_packet_list_A)) { + SAMPLES_NEEDED_2("too many packet bytes"); + return; + } + q->sub_packet_list_A[i].next = NULL; if (i > 0) { diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index a8fe38a7e8..2933d6dbfe 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -67,7 +67,7 @@ static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change) * line' at the beginning. Since we always interpret it as 'go to next line' * in the decoding loop (which makes code simpler/faster), the first line * would not be counted, so we count one more. - * See: https://ffmpeg.org/trac/ffmpeg/ticket/226 + * See: https://trac.ffmpeg.org/ticket/226 * In the following decoding loop, row_ptr will be the position of the * _next_ row. */ lines_to_change++; diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index e0fb827856..bdb1d9bfac 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -536,7 +536,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, for (; i < frame->nb_samples; i++) ractx->curr_block[i] = samples[i] >> 2; - if ((ret = ff_af_queue_add(&ractx->afq, frame) < 0)) + if ((ret = ff_af_queue_add(&ractx->afq, frame)) < 0) return ret; } else ractx->last_frame = 1; diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index b4cf454e9a..229022be8b 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -169,6 +169,12 @@ static av_cold int roq_decode_init(AVCodecContext *avctx) RoqContext *s = avctx->priv_data; s->avctx = avctx; + + if (avctx->width%16 || avctx->height%16) { + av_log_ask_for_sample(avctx, "dimensions not being a multiple of 16 are unsupported\n"); + return AVERROR_PATCHWELCOME; + } + s->width = avctx->width; s->height = avctx->height; avcodec_get_frame_defaults(&s->frames[0]); diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index b12bf04fa2..d37990aa74 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -84,7 +84,7 @@ static void rpza_decode_stream(RpzaContext *s) unsigned short *pixels = (unsigned short *)s->frame.data[0]; int row_ptr = 0; - int pixel_ptr = 0; + int pixel_ptr = -4; int block_ptr; int pixel_x, pixel_y; int total_blocks; @@ -140,6 +140,7 @@ static void rpza_decode_stream(RpzaContext *s) colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; while (n_blocks--) { + ADVANCE_BLOCK() block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ @@ -148,7 +149,6 @@ static void rpza_decode_stream(RpzaContext *s) } block_ptr += row_inc; } - ADVANCE_BLOCK(); } break; @@ -187,6 +187,7 @@ static void rpza_decode_stream(RpzaContext *s) if (s->size - stream_ptr < n_blocks * 4) return; while (n_blocks--) { + ADVANCE_BLOCK(); block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { index = s->buf[stream_ptr++]; @@ -197,7 +198,6 @@ static void rpza_decode_stream(RpzaContext *s) } block_ptr += row_inc; } - ADVANCE_BLOCK(); } break; @@ -205,6 +205,7 @@ static void rpza_decode_stream(RpzaContext *s) case 0x00: if (s->size - stream_ptr < 16) return; + ADVANCE_BLOCK(); block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ @@ -218,7 +219,6 @@ static void rpza_decode_stream(RpzaContext *s) } block_ptr += row_inc; } - ADVANCE_BLOCK(); break; /* Unknown opcode */ diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index 3736bd74ec..77811af92f 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -25,6 +25,7 @@ #include "avcodec.h" #include "bytestream.h" #include "libavutil/bswap.h" +#include "libavutil/imgutils.h" #include "libavcodec/dsputil.h" #include "sanm_data.h" @@ -414,6 +415,11 @@ static int old_codec37(SANMVideoContext *ctx, int top, flags = bytestream2_get_byte(&ctx->gb); bytestream2_skip(&ctx->gb, 3); + if (decoded_size > ctx->height * stride - left - top * stride) { + decoded_size = ctx->height * stride - left - top * stride; + av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n"); + } + ctx->rotate_code = 0; if (((seq & 1) || !(flags & 1)) && (compr && compr != 2)) @@ -637,6 +643,11 @@ static int old_codec47(SANMVideoContext *ctx, int top, decoded_size = bytestream2_get_le32(&ctx->gb); bytestream2_skip(&ctx->gb, 8); + if (decoded_size > ctx->height * stride - left - top * stride) { + decoded_size = ctx->height * stride - left - top * stride; + av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n"); + } + if (skip & 1) bytestream2_skip(&ctx->gb, 0x8080); if (!seq) { @@ -714,9 +725,17 @@ static int process_frame_obj(SANMVideoContext *ctx) w = bytestream2_get_le16u(&ctx->gb); h = bytestream2_get_le16u(&ctx->gb); + if (!w || !h) { + av_log(ctx->avctx, AV_LOG_ERROR, "dimensions are invalid\n"); + return AVERROR_INVALIDDATA; + } + if (ctx->width < left + w || ctx->height < top + h) { - ctx->avctx->width = FFMAX(left + w, ctx->width); - ctx->avctx->height = FFMAX(top + h, ctx->height); + if (av_image_check_size(FFMAX(left + w, ctx->width), + FFMAX(top + h, ctx->height), 0, ctx->avctx) < 0) + return AVERROR_INVALIDDATA; + avcodec_set_dimensions(ctx->avctx, FFMAX(left + w, ctx->width), + FFMAX(top + h, ctx->height)); init_sizes(ctx, left + w, top + h); if (init_buffers(ctx)) { av_log(ctx->avctx, AV_LOG_ERROR, "error resizing buffers\n"); diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index d04011e468..470b467b8c 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -342,6 +342,7 @@ static int read_header(ShortenContext *s) s->channels = get_uint(s, CHANSIZE); if (s->channels > MAX_CHANNELS) { av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); + s->channels = 0; return -1; } s->avctx->channels = s->channels; diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 4913625e37..f2bfdd2346 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -687,7 +687,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, } val |= h[3].values[res] << 8; pred[1] += sign_extend(val, 16); - *samples++ = av_clip_int16(pred[1]); + *samples++ = pred[1]; } else { if(vlc[0].table) res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3); @@ -708,7 +708,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, } val |= h[1].values[res] << 8; pred[0] += sign_extend(val, 16); - *samples++ = av_clip_int16(pred[0]); + *samples++ = pred[0]; } } } else { //8-bit data diff --git a/libavcodec/snow.h b/libavcodec/snow.h index 6d6b086907..675c054962 100644 --- a/libavcodec/snow.h +++ b/libavcodec/snow.h @@ -312,7 +312,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer if(!sliced && !offset_dst) dst -= src_x; src_x=0; - }else if(src_x + b_w > w){ + } + if(src_x + b_w > w){ b_w = w - src_x; } if(src_y<0){ @@ -321,7 +322,8 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer if(!sliced && !offset_dst) dst -= src_y*dst_stride; src_y=0; - }else if(src_y + b_h> h){ + } + if(src_y + b_h> h){ b_h = h - src_y; } diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 579bd0d5f7..0d2aee70fd 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -207,9 +207,11 @@ static char *doubles2str(double *dp, int count, const char *sep) { int i; char *ap, *ap0; - int component_len = 15 + strlen(sep); + uint64_t component_len = 15LL + strlen(sep); if (!sep) sep = ", "; - ap = av_malloc(component_len * count); + if (count >= (INT_MAX - 1)/component_len) + return NULL; + ap = av_malloc(component_len * count + 1); if (!ap) return NULL; ap0 = ap; @@ -228,14 +230,22 @@ static char *shorts2str(int16_t *sp, int count, const char *sep) { int i; char *ap, *ap0; + uint64_t component_len; if (!sep) sep = ", "; - ap = av_malloc((5 + strlen(sep)) * count); + component_len = 7LL + strlen(sep); + if (count >= (INT_MAX - 1)/component_len) + return NULL; + ap = av_malloc(component_len * count + 1); if (!ap) return NULL; ap0 = ap; ap[0] = '\0'; for (i = 0; i < count; i++) { - int l = snprintf(ap, 5 + strlen(sep), "%d%s", sp[i], sep); + unsigned l = snprintf(ap, component_len, "%d%s", sp[i], sep); + if (l >= component_len) { + av_free(ap0); + return NULL; + } ap += l; } ap0[strlen(ap0) - strlen(sep)] = '\0'; @@ -250,7 +260,7 @@ static int add_doubles_metadata(int count, int i; double *dp; - if (count >= INT_MAX / sizeof(int64_t)) + if (count >= INT_MAX / sizeof(int64_t) || count <= 0) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int64_t)) return AVERROR_INVALIDDATA; @@ -276,7 +286,7 @@ static int add_shorts_metadata(int count, const char *name, int i; int16_t *sp; - if (count >= INT_MAX / sizeof(int16_t)) + if (count >= INT_MAX / sizeof(int16_t) || count <= 0) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t)) return AVERROR_INVALIDDATA; @@ -737,7 +747,7 @@ static int tiff_decode_tag(TiffContext *s) break; case TIFF_ROWSPERSTRIP: if (type == TIFF_LONG && value == UINT_MAX) - value = s->avctx->height; + value = s->height; if (value < 1) { av_log(s->avctx, AV_LOG_ERROR, "Incorrect value of rows per strip\n"); @@ -843,7 +853,7 @@ static int tiff_decode_tag(TiffContext *s) s->fax_opts = value; break; #define ADD_METADATA(count, name, sep)\ - if (ret = add_metadata(count, type, name, sep, s) < 0) {\ + if ((ret = add_metadata(count, type, name, sep, s)) < 0) {\ av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\ return ret;\ } diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index e9fcf4db46..5a8648351f 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -922,14 +922,14 @@ static av_cold int decode_init(AVCodecContext *avctx){ if (!l->Y1_base || !l->Y2_base || !l->U1_base || !l->V1_base || !l->U2_base || !l->V2_base || !l->last || !l->clast) { - av_freep(l->Y1_base); - av_freep(l->Y2_base); - av_freep(l->U1_base); - av_freep(l->U2_base); - av_freep(l->V1_base); - av_freep(l->V2_base); - av_freep(l->last); - av_freep(l->clast); + av_freep(&l->Y1_base); + av_freep(&l->Y2_base); + av_freep(&l->U1_base); + av_freep(&l->U2_base); + av_freep(&l->V1_base); + av_freep(&l->V2_base); + av_freep(&l->last); + av_freep(&l->clast); return AVERROR(ENOMEM); } l->Y1 = l->Y1_base + l->y_stride * 4 + 4; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 00434c9114..8cce59bbf4 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1703,7 +1703,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n", avctx->internal->skip_samples); } - if (avctx->internal->skip_samples) { + if (avctx->internal->skip_samples && *got_frame_ptr) { if(frame->nb_samples <= avctx->internal->skip_samples){ *got_frame_ptr = 0; avctx->internal->skip_samples -= frame->nb_samples; @@ -1744,7 +1744,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, * make sure it's set correctly; assume decoders that actually use * extended_data are doing it correctly */ planar = av_sample_fmt_is_planar(frame->format); - channels = av_get_channel_layout_nb_channels(frame->channel_layout); + channels = frame->channels; if (!(planar && channels > AV_NUM_DATA_POINTERS)) frame->extended_data = frame->data; diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index fe5636fd0b..9e1edd3376 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -468,7 +468,7 @@ static int encode_plane(AVCodecContext *avctx, uint8_t *src, * get the offset in bits and convert to bytes. */ offset += write_huff_codes(dst + sstart * width, c->slice_bits, - width * (send - sstart), width, + width * height + 4, width, send - sstart, he) >> 3; slice_len = offset - slice_len; @@ -525,8 +525,7 @@ static int utvideo_encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytestream2_init_writer(&pb, dst, pkt->size); - av_fast_malloc(&c->slice_bits, &c->slice_bits_size, - width * height + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_padded_malloc(&c->slice_bits, &c->slice_bits_size, width * height + 4); if (!c->slice_bits) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n"); diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index d7352d3671..deb4efe8ad 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -583,6 +583,8 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) { int pqindex, lowquant, status; + v->field_mode = 0; + v->fcm = 0; if (v->finterpflag) v->interpfrm = get_bits1(gb); if (!v->s.avctx->codec) diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 3834416857..b838781345 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -160,7 +160,7 @@ static int rle_unpack(const unsigned char *src, int src_len, int src_count, const unsigned char *ps; const unsigned char *ps_end; unsigned char *pd; - int i, l; + int i, j, l; unsigned char *dest_end = dest + dest_len; ps = src; @@ -186,9 +186,9 @@ static int rle_unpack(const unsigned char *src, int src_len, int src_count, ps += l; pd += l; } else { - if (dest_end - pd < i || ps_end - ps < 2) + if (dest_end - pd < 2*l || ps_end - ps < 2) return ps - src; - for (i = 0; i < l; i++) { + for (j = 0; j < l; j++) { *pd++ = ps[0]; *pd++ = ps[1]; } diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c index 6d091c1bd2..417109b8bd 100644 --- a/libavcodec/vmnc.c +++ b/libavcodec/vmnc.c @@ -276,6 +276,11 @@ static int decode_hextile(VmncContext *c, uint8_t* dst, const uint8_t* src, int } xy = *src++; wh = *src++; + if ( (xy >> 4) + (wh >> 4) + 1 > w - i + || (xy & 0xF) + (wh & 0xF)+1 > h - j) { + av_log(c->avctx, AV_LOG_ERROR, "Rectangle outside picture\n"); + return AVERROR_INVALIDDATA; + } paint_rect(dst2, xy >> 4, xy & 0xF, (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride); } } diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 8ce0fc7c83..0ea73d5183 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -599,6 +599,10 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) "Floor 0 amplitude bits is 0.\n"); return AVERROR_INVALIDDATA; } + if (floor_setup->data.t0.bark_map_size == 0) { + av_log(vc->avccontext, AV_LOG_ERROR, "Floor 0 bark map size is 0.\n"); + return AVERROR_INVALIDDATA; + } floor_setup->data.t0.amplitude_offset = get_bits(gb, 8); floor_setup->data.t0.num_books = get_bits(gb, 4) + 1; diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h index 4f026dfe8d..1d1396989b 100644 --- a/libavcodec/vp8.h +++ b/libavcodec/vp8.h @@ -34,6 +34,8 @@ #include #elif HAVE_W32THREADS #include "w32pthreads.h" +#elif HAVE_OS2THREADS +#include "os2threads.h" #endif #define VP8_MAX_QUANT 127 diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index e4bad00ca1..33f7083b9c 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -536,6 +536,11 @@ static int vqa_decode_chunk(VqaContext *s) bytestream2_seek(&s->gb, cbp0_chunk, SEEK_SET); chunk_size = bytestream2_get_be32(&s->gb); + if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) { + av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size); + return AVERROR_INVALIDDATA; + } + /* accumulate partial codebook */ bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index], chunk_size); @@ -559,6 +564,11 @@ static int vqa_decode_chunk(VqaContext *s) bytestream2_seek(&s->gb, cbpz_chunk, SEEK_SET); chunk_size = bytestream2_get_be32(&s->gb); + if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) { + av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size); + return AVERROR_INVALIDDATA; + } + /* accumulate partial codebook */ bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index], chunk_size); @@ -566,9 +576,7 @@ static int vqa_decode_chunk(VqaContext *s) s->partial_countdown--; if (s->partial_countdown <= 0) { - GetByteContext gb; - - bytestream2_init(&gb, s->next_codebook_buffer, s->next_codebook_buffer_index); + bytestream2_init(&s->gb, s->next_codebook_buffer, s->next_codebook_buffer_index); /* decompress codebook */ if ((res = decode_format80(s, s->next_codebook_buffer_index, s->codebook, s->codebook_size, 0)) < 0) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index ef4fc4f10d..4be84c754e 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1206,11 +1206,12 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data, } /* get output buffer */ - s->frame.nb_samples = s->samples; + s->frame.nb_samples = s->samples + 1; if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } + s->frame.nb_samples = s->samples; while (buf_size > 0) { if (!s->multichannel) { diff --git a/libavcodec/wma.c b/libavcodec/wma.c index d5e66e25b3..936d5ec6ef 100644 --- a/libavcodec/wma.c +++ b/libavcodec/wma.c @@ -385,9 +385,9 @@ int ff_wma_end(AVCodecContext *avctx) } for (i = 0; i < 2; i++) { ff_free_vlc(&s->coef_vlc[i]); - av_free(s->run_table[i]); - av_free(s->level_table[i]); - av_free(s->int_table[i]); + av_freep(&s->run_table[i]); + av_freep(&s->level_table[i]); + av_freep(&s->int_table[i]); } return 0; diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 39e50a4ffd..fa0d747f8a 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -524,6 +524,10 @@ static int wma_decode_block(WMACodecContext *s) coef escape coding */ total_gain = 1; for(;;) { + if (get_bits_left(&s->gb) < 7) { + av_log(s->avctx, AV_LOG_ERROR, "total_gain overread\n"); + return AVERROR_INVALIDDATA; + } a = get_bits(&s->gb, 7); total_gain += a; if (a != 127) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 485cab206c..ba4d7edac4 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -125,8 +125,8 @@ typedef struct WmallDecodeCtx { int8_t mclms_order; int8_t mclms_scaling; - int16_t mclms_coeffs[128]; - int16_t mclms_coeffs_cur[4]; + int16_t mclms_coeffs[WMALL_MAX_CHANNELS * WMALL_MAX_CHANNELS * 32]; + int16_t mclms_coeffs_cur[WMALL_MAX_CHANNELS * WMALL_MAX_CHANNELS]; int16_t mclms_prevvalues[WMALL_MAX_CHANNELS * 2 * 32]; int16_t mclms_updates[WMALL_MAX_CHANNELS * 2 * 32]; int mclms_recent; diff --git a/libavcodec/x86/idct_sse2_xvid.c b/libavcodec/x86/idct_sse2_xvid.c index d121b25031..bb424eed6f 100644 --- a/libavcodec/x86/idct_sse2_xvid.c +++ b/libavcodec/x86/idct_sse2_xvid.c @@ -344,7 +344,7 @@ DECLARE_ASM_CONST(16, int32_t, walkenIdctRounders)[] = { "movdqa %%xmm6, 4*16("dct") \n\t" \ "movdqa "SREG2", 7*16("dct") \n\t" -inline void ff_idct_xvid_sse2(short *block) +av_extern_inline void ff_idct_xvid_sse2(short *block) { __asm__ volatile( "movq "MANGLE(m127)", %%mm0 \n\t" diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 79e29e6232..76ea1315c2 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -74,7 +74,7 @@ static av_always_inline av_const int64_t MUL64(int a, int b) static inline av_const int mid_pred(int a, int b, int c) { int i=b; - __asm__ volatile( + __asm__ ( "cmp %2, %1 \n\t" "cmovg %1, %0 \n\t" "cmovg %2, %1 \n\t" diff --git a/libavcodec/x86/mpegvideo.c b/libavcodec/x86/mpegvideo.c index 2d475abe01..227fbc070c 100644 --- a/libavcodec/x86/mpegvideo.c +++ b/libavcodec/x86/mpegvideo.c @@ -26,7 +26,7 @@ #include "libavcodec/mpegvideo.h" #include "dsputil_mmx.h" -#if HAVE_INLINE_ASM +#if HAVE_MMX_INLINE static void dct_unquantize_h263_intra_mmx(MpegEncContext *s, DCTELEM *block, int n, int qscale) @@ -582,11 +582,11 @@ static void denoise_dct_sse2(MpegEncContext *s, DCTELEM *block){ ); } -#endif /* HAVE_INLINE_ASM */ +#endif /* HAVE_MMX_INLINE */ void ff_MPV_common_init_x86(MpegEncContext *s) { -#if HAVE_INLINE_ASM +#if HAVE_MMX_INLINE int mm_flags = av_get_cpu_flags(); if (mm_flags & AV_CPU_FLAG_MMX) { @@ -604,5 +604,5 @@ void ff_MPV_common_init_x86(MpegEncContext *s) s->denoise_dct= denoise_dct_mmx; } } -#endif /* HAVE_INLINE_ASM */ +#endif /* HAVE_MMX_INLINE */ } diff --git a/libavcodec/x86/mpegvideoenc_template.c b/libavcodec/x86/mpegvideoenc_template.c index d874f39ec7..8ec193ef16 100644 --- a/libavcodec/x86/mpegvideoenc_template.c +++ b/libavcodec/x86/mpegvideoenc_template.c @@ -216,7 +216,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s, "psubusw "MM"1, "MM"4 \n\t" "packuswb "MM"4, "MM"4 \n\t" #if COMPILE_TEMPLATE_SSE2 - "packuswb "MM"4, "MM"4 \n\t" + "packsswb "MM"4, "MM"4 \n\t" #endif "movd "MM"4, %0 \n\t" // *overflow : "=g" (*overflow) diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index 626e8de040..871704e972 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -57,7 +57,7 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data, int number, len; ptr += strcspn(ptr, "#"); - if (sscanf(ptr, "#define %256s %u", name, &number) != 2) { + if (sscanf(ptr, "#define %255s %u", name, &number) != 2) { av_log(avctx, AV_LOG_ERROR, "Unexpected preprocessor directive\n"); return AVERROR_INVALIDDATA; } diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c index c0bd621cb4..b3aed3ccde 100644 --- a/libavfilter/avf_concat.c +++ b/libavfilter/avf_concat.c @@ -195,7 +195,7 @@ static void process_frame(AVFilterLink *inlink, AVFilterBufferRef *buf) av_log(ctx, AV_LOG_ERROR, "Frame after EOF on input %s\n", ctx->input_pads[in_no].name); avfilter_unref_buffer(buf); - } if (in_no >= cat->cur_idx + ctx->nb_outputs) { + } else if (in_no >= cat->cur_idx + ctx->nb_outputs) { ff_bufqueue_add(ctx, &cat->in[in_no].queue, buf); } else { push_frame(ctx, in_no, buf); diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c index dcbe8b8a61..81ee74d066 100644 --- a/libavfilter/avf_showwaves.c +++ b/libavfilter/avf_showwaves.c @@ -220,6 +220,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) } if (showwaves->buf_idx == showwaves->w) push_frame(outlink); + outpicref = showwaves->outpicref; } avfilter_unref_buffer(insamples); diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 9f49a8b2b1..11e880b379 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -112,9 +112,9 @@ void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, (*links)[idx] = NULL; (*count)++; - for (i = idx+1; i < *count; i++) - if (*links[i]) - (*(unsigned *)((uint8_t *) *links[i] + padidx_off))++; + for (i = idx + 1; i < *count; i++) + if ((*links)[i]) + (*(unsigned *)((uint8_t *) (*links)[i] + padidx_off))++; } int avfilter_link(AVFilterContext *src, unsigned srcpad, diff --git a/libavfilter/filtfmts.c b/libavfilter/filtfmts.c index 14417cbd4b..e2a542a869 100644 --- a/libavfilter/filtfmts.c +++ b/libavfilter/filtfmts.c @@ -41,7 +41,7 @@ static void print_formats(AVFilterContext *filter_ctx) for (j = 0; j < fmts->format_count; j++) \ if(av_get_pix_fmt_name(fmts->formats[j])) \ printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ - i, filter_ctx->filter->inout##puts[i].name, \ + i, filter_ctx->inout##put_pads[i].name, \ av_get_pix_fmt_name(fmts->formats[j])); \ } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \ AVFilterFormats *fmts; \ @@ -50,7 +50,7 @@ static void print_formats(AVFilterContext *filter_ctx) fmts = filter_ctx->inout##puts[i]->outin##_formats; \ for (j = 0; j < fmts->format_count; j++) \ printf(#INOUT "PUT[%d] %s: fmt:%s\n", \ - i, filter_ctx->filter->inout##puts[i].name, \ + i, filter_ctx->inout##put_pads[i].name, \ av_get_sample_fmt_name(fmts->formats[j])); \ \ layouts = filter_ctx->inout##puts[i]->outin##_channel_layouts; \ @@ -59,7 +59,7 @@ static void print_formats(AVFilterContext *filter_ctx) av_get_channel_layout_string(buf, sizeof(buf), -1, \ layouts->channel_layouts[j]); \ printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ - i, filter_ctx->filter->inout##puts[i].name, buf); \ + i, filter_ctx->inout##put_pads[i].name, buf); \ } \ } \ } \ @@ -109,12 +109,12 @@ int main(int argc, char **argv) /* create a link for each of the input pads */ for (i = 0; i < filter_ctx->input_count; i++) { AVFilterLink *link = av_mallocz(sizeof(AVFilterLink)); - link->type = filter_ctx->filter->inputs[i].type; + link->type = filter_ctx->input_pads[i].type; filter_ctx->inputs[i] = link; } for (i = 0; i < filter_ctx->output_count; i++) { AVFilterLink *link = av_mallocz(sizeof(AVFilterLink)); - link->type = filter_ctx->filter->outputs[i].type; + link->type = filter_ctx->output_pads[i].type; filter_ctx->outputs[i] = link; } diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c index c9d0fb0a7c..c0db843414 100644 --- a/libavfilter/graphdump.c +++ b/libavfilter/graphdump.c @@ -31,9 +31,10 @@ static int print_link_prop(AVBPrint *buf, AVFilterLink *link) { char *format; char layout[64]; + AVBPrint dummy_buffer = { 0 }; if (!buf) - buf = &(AVBPrint){ 0 }; /* dummy buffer */ + buf = &dummy_buffer; switch (link->type) { case AVMEDIA_TYPE_VIDEO: format = av_x_if_null(av_get_pix_fmt_name(link->format), "?"); diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 8ebad6d8ca..156e6d1b88 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -91,13 +91,13 @@ static int movie_request_frame(AVFilterLink *outlink); static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) { int i, ret, already = 0, stream_id = -1; - char type_char, dummy; + char type_char[2], dummy; AVStream *found = NULL; enum AVMediaType type; - ret = sscanf(spec, "d%[av]%d%c", &type_char, &stream_id, &dummy); + ret = sscanf(spec, "d%1[av]%d%c", type_char, &stream_id, &dummy); if (ret >= 1 && ret <= 2) { - type = type_char == 'v' ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO; + type = type_char[0] == 'v' ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO; ret = av_find_best_stream(avf, type, stream_id, -1, NULL, 0); if (ret < 0) { av_log(log, AV_LOG_ERROR, "No %s stream with index '%d' found\n", diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index ac0a0139c0..f365aa2e30 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -317,8 +317,8 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2, //av_log(NULL, AV_LOG_ERROR, "\n"); } - p_x = (center_x - width / 2); - p_y = (center_y - height / 2); + p_x = (center_x - width / 2.0); + p_y = (center_y - height / 2.0); t->vector.x += (cos(t->angle)-1)*p_x - sin(t->angle)*p_y; t->vector.y += sin(t->angle)*p_x + (cos(t->angle)-1)*p_y; diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index c13b1bd385..3d355cff1a 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -201,7 +201,7 @@ static int end_frame(AVFilterLink *inlink) } /* now wait for the next timestamp */ - if (buf->pts == AV_NOPTS_VALUE) { + if (buf->pts == AV_NOPTS_VALUE || av_fifo_size(s->fifo) <= 0) { return write_to_fifo(s->fifo, buf); } diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c index 8942ced4f3..56a3c20a54 100644 --- a/libavfilter/vf_idet.c +++ b/libavfilter/vf_idet.c @@ -176,6 +176,7 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) idet->prev = idet->cur; idet->cur = idet->next; idet->next = picref; + link->cur_buf = NULL; if (!idet->cur) return 0; diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 85d3789cec..215379d5da 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -254,7 +254,7 @@ static int color_config_props(AVFilterLink *inlink) if (av_image_check_size(test->w, test->h, 0, ctx) < 0) return AVERROR(EINVAL); - if (ret = config_props(inlink) < 0) + if ((ret = config_props(inlink)) < 0) return ret; av_log(ctx, AV_LOG_VERBOSE, "color:0x%02x%02x%02x%02x\n", diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 41fe0d2994..f5c752005f 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -191,7 +191,7 @@ static int aiff_probe(AVProbeData *p) static int aiff_read_header(AVFormatContext *s) { int size, filesize; - int64_t offset = 0; + int64_t offset = 0, position; uint32_t tag; unsigned version = AIFF_C_VERSION1; AVIOContext *pb = s->pb; @@ -235,8 +235,11 @@ static int aiff_read_header(AVFormatContext *s) goto got_sound; break; case MKTAG('I', 'D', '3', ' '): + position = avio_tell(pb); ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta); ff_id3v2_free_extra_meta(&id3v2_extra_meta); + if (position + size > avio_tell(pb)) + avio_skip(pb, position + size - avio_tell(pb)); break; case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */ version = avio_rb32(pb); diff --git a/libavformat/asf.h b/libavformat/asf.h index 5562865f68..9a32a41c70 100644 --- a/libavformat/asf.h +++ b/libavformat/asf.h @@ -28,6 +28,11 @@ #define PACKET_SIZE 3200 +typedef struct ASFPayload { + uint8_t type; + uint16_t size; +} ASFPayload; + typedef struct { int num; unsigned char seq; @@ -47,6 +52,9 @@ typedef struct { int palette_changed; uint32_t palette[256]; + + int payload_ext_ct; + ASFPayload payload[8]; } ASFStream; typedef struct { diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index b1b8eeb303..20f212fcd2 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -513,8 +513,10 @@ static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size) stream_ct = avio_rl16(pb); //stream-name-count payload_ext_ct = avio_rl16(pb); //payload-extension-system-count - if (stream_num < 128) + if (stream_num < 128) { asf->stream_bitrates[stream_num] = leak_rate; + asf->streams[stream_num].payload_ext_ct = 0; + } for (i=0; istreams[stream_num].payload)) { + ASFPayload *p = &asf->streams[stream_num].payload[i]; + p->type = g[0]; + p->size = size; + av_log(s, AV_LOG_DEBUG, "Payload extension %x %d\n", g[0], p->size ); + asf->streams[stream_num].payload_ext_ct ++; + } } return 0; @@ -776,12 +786,12 @@ static int asf_read_header(AVFormatContext *s) if (!st->codec->bit_rate) st->codec->bit_rate = asf->stream_bitrates[i]; if (asf->dar[i].num > 0 && asf->dar[i].den > 0){ - av_reduce(&st->sample_aspect_ratio.den, - &st->sample_aspect_ratio.num, + av_reduce(&st->sample_aspect_ratio.num, + &st->sample_aspect_ratio.den, asf->dar[i].num, asf->dar[i].den, INT_MAX); } else if ((asf->dar[0].num > 0) && (asf->dar[0].den > 0) && (st->codec->codec_type==AVMEDIA_TYPE_VIDEO)) // Use ASF container value if the stream doesn't AR set. - av_reduce(&st->sample_aspect_ratio.den, - &st->sample_aspect_ratio.num, + av_reduce(&st->sample_aspect_ratio.num, + &st->sample_aspect_ratio.den, asf->dar[0].num, asf->dar[0].den, INT_MAX); //av_log(s, AV_LOG_INFO, "i=%d, st->codec->codec_type:%d, dar %d:%d sar=%d:%d\n", i, st->codec->codec_type, dar[i].num, dar[i].den, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); @@ -915,13 +925,16 @@ static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb) */ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ ASFContext *asf = s->priv_data; + ASFStream *asfst; int rsize = 1; int num = avio_r8(pb); + int i; int64_t ts0, ts1 av_unused; asf->packet_segments--; asf->packet_key_frame = num >> 7; asf->stream_index = asf->asfid2avid[num & 0x7f]; + asfst = &asf->streams[num & 0x7f]; // sequence should be ignored! DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0); DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0); @@ -932,26 +945,56 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ return AVERROR_INVALIDDATA; } if (asf->packet_replic_size >= 8) { + int64_t end = avio_tell(pb) + asf->packet_replic_size; + AVRational aspect; asf->packet_obj_size = avio_rl32(pb); if(asf->packet_obj_size >= (1<<24) || asf->packet_obj_size <= 0){ av_log(s, AV_LOG_ERROR, "packet_obj_size invalid\n"); return AVERROR_INVALIDDATA; } asf->packet_frag_timestamp = avio_rl32(pb); // timestamp - if(asf->packet_replic_size >= 8+38+4){ -// for(i=0; ipacket_replic_size-8; i++) -// av_log(s, AV_LOG_DEBUG, "%02X ",avio_r8(pb)); -// av_log(s, AV_LOG_DEBUG, "\n"); - avio_skip(pb, 10); - ts0= avio_rl64(pb); - ts1= avio_rl64(pb); - avio_skip(pb, 12); - avio_rl32(pb); - avio_skip(pb, asf->packet_replic_size - 8 - 38 - 4); - if(ts0!= -1) asf->packet_frag_timestamp= ts0/10000; - else asf->packet_frag_timestamp= AV_NOPTS_VALUE; - }else - avio_skip(pb, asf->packet_replic_size - 8); + + for (i=0; ipayload_ext_ct; i++) { + ASFPayload *p = &asfst->payload[i]; + int size = p->size; + int64_t payend; + if(size == 0xFFFF) + size = avio_rl16(pb); + payend = avio_tell(pb) + size; + if (payend > end) { + av_log(s, AV_LOG_ERROR, "too long payload\n"); + break; + } + switch(p->type) { + case 0x50: +// duration = avio_rl16(pb); + break; + case 0x54: + aspect.num = avio_r8(pb); + aspect.den = avio_r8(pb); + if (aspect.num > 0 && aspect.den > 0 && asf->stream_index >= 0) { + s->streams[asf->stream_index]->sample_aspect_ratio = aspect; + } + break; + case 0x2A: + avio_skip(pb, 8); + ts0= avio_rl64(pb); + ts1= avio_rl64(pb); + if(ts0!= -1) asf->packet_frag_timestamp= ts0/10000; + else asf->packet_frag_timestamp= AV_NOPTS_VALUE; + break; + case 0x5B: + case 0xB7: + case 0xCC: + case 0xC0: + case 0xA0: + //unknown + break; + } + avio_seek(pb, payend, SEEK_SET); + } + + avio_seek(pb, end, SEEK_SET); rsize += asf->packet_replic_size; // FIXME - check validity } else if (asf->packet_replic_size==1){ // multipacket - frag_offset is beginning timestamp diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index 8d169f7e2e..82681d24f1 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -579,6 +579,9 @@ static int asf_write_header(AVFormatContext *s) ffio_init_context(&asf->pb, asf->packet_buf, s->packet_size, 1, NULL, NULL, NULL, NULL); + if (s->avoid_negative_ts < 0) + s->avoid_negative_ts = 1; + return 0; } diff --git a/libavformat/avidec.c b/libavformat/avidec.c index c4d41e5449..ce621d6729 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -695,7 +695,9 @@ static int avi_read_header(AVFormatContext *s) } break; case MKTAG('s', 't', 'r', 'd'): - if (stream_index >= (unsigned)s->nb_streams || s->streams[stream_index]->codec->extradata_size) { + if (stream_index >= (unsigned)s->nb_streams + || s->streams[stream_index]->codec->extradata_size + || s->streams[stream_index]->codec->codec_tag == MKTAG('H','2','6','4')) { avio_skip(pb, size); } else { uint64_t cur_pos = avio_tell(pb); @@ -988,9 +990,9 @@ start_sync: || st->discard >= AVDISCARD_ALL){ if (!exit_early) { ast->frame_offset += get_duration(ast, size); + avio_skip(pb, size); + goto start_sync; } - avio_skip(pb, size); - goto start_sync; } if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) { @@ -1262,6 +1264,11 @@ static int avi_read_idx1(AVFormatContext *s, int size) avi->stream_index = -1; avio_seek(pb, idx1_pos, SEEK_SET); + if (s->nb_streams == 1 && s->streams[0]->codec->codec_tag == AV_RL32("MMES")){ + first_packet_pos = 0; + data_offset = avi->movi_list; + } + /* Read the entries and sort them in each stream component. */ for(i = 0; i < nb_index_entries; i++) { if(url_feof(pb)) @@ -1281,7 +1288,7 @@ static int avi_read_idx1(AVFormatContext *s, int size) st = s->streams[index]; ast = st->priv_data; - if(first_packet && first_packet_pos && len) { + if (first_packet && first_packet_pos) { data_offset = first_packet_pos - pos; first_packet = 0; } diff --git a/libavformat/avienc.c b/libavformat/avienc.c index 0352f8bd66..ea7bc3fdb6 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -525,7 +525,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) int size= pkt->size; // av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %d\n", pkt->dts, avist->packet_count, stream_index); - while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count && enc->codec_id != AV_CODEC_ID_XSUB){ + while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count && enc->codec_id != AV_CODEC_ID_XSUB && avist->packet_count){ AVPacket empty_packet; if(pkt->dts - avist->packet_count > 60000){ diff --git a/libavformat/avio.c b/libavformat/avio.c index abc70723ef..d7240f34de 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -209,7 +209,9 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags, "Missing call to av_register_all()?\n"); } - if (filename[proto_len] != ':' && filename[proto_len] != ',' || is_dos_path(filename)) + if (filename[proto_len] != ':' && + (filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) || + is_dos_path(filename)) strcpy(proto_str, "file"); else av_strlcpy(proto_str, filename, FFMIN(proto_len+1, sizeof(proto_str))); diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c index 5c05758327..009dd5c456 100644 --- a/libavformat/dtsdec.c +++ b/libavformat/dtsdec.c @@ -34,6 +34,7 @@ static int dts_probe(AVProbeData *p) uint32_t state = -1; int markers[3] = {0}; int sum, max; + int64_t diff = 0; buf = p->buf; @@ -54,12 +55,16 @@ static int dts_probe(AVProbeData *p) if (state == DCA_MARKER_14B_LE) if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007) markers[2]++; + + if (buf - p->buf >= 4) + diff += FFABS(AV_RL16(buf) - AV_RL16(buf-4)); } sum = markers[0] + markers[1] + markers[2]; max = markers[1] > markers[0]; max = markers[2] > markers[max] ? 2 : max; if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 && - markers[max] * 4 > sum * 3) + markers[max] * 4 > sum * 3 && + diff / p->buf_size > 200) return AVPROBE_SCORE_MAX/2+1; return 0; diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 604f4ce833..faeb8fdf8e 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -376,8 +376,8 @@ static int dv_write_header(AVFormatContext *s) break; } } - if (tcr) - return av_timecode_init_from_string(&dvc->tc, rate, tcr->value, s); + if (tcr && av_timecode_init_from_string(&dvc->tc, rate, tcr->value, s) >= 0) + return 0; return av_timecode_init(&dvc->tc, rate, 0, 0, s); } diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 8c6807a260..d19cf240b1 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -712,13 +712,13 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) st = s->streams[i]; if (stream_type == FLV_STREAM_TYPE_AUDIO) { if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && - flv_same_audio_codec(st->codec, flags)) { + (s->audio_codec_id || flv_same_audio_codec(st->codec, flags))) { break; } } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && - flv_same_video_codec(st->codec, flags)) { + (s->video_codec_id || flv_same_video_codec(st->codec, flags))) { break; } } else if (stream_type == FLV_STREAM_TYPE_DATA) { diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 97c00bf79e..6131bef17c 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -218,6 +218,18 @@ static int flv_write_header(AVFormatContext *s) avcodec_get_name(enc->codec_id), i); return AVERROR(EINVAL); } + if (enc->codec_id == AV_CODEC_ID_MPEG4 || + enc->codec_id == AV_CODEC_ID_H263) { + int error = enc->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL; + av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING, + "Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(enc->codec_id)); + + if (error) { + av_log(s, AV_LOG_ERROR, + "use vstrict=-1 / -strict -1 to use it anyway.\n"); + return AVERROR(EINVAL); + } + } break; case AVMEDIA_TYPE_AUDIO: audio_enc = enc; @@ -492,10 +504,13 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) return ret; } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { + if (!s->streams[pkt->stream_index]->nb_frames) { av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: " "use audio bistream filter 'aac_adtstoasc' to fix it " "('-bsf:a aac_adtstoasc' option with ffmpeg)\n"); return AVERROR_INVALIDDATA; + } + av_log(s, AV_LOG_WARNING, "aac bitstream error\n"); } if (flv->delay == AV_NOPTS_VALUE) diff --git a/libavformat/h263dec.c b/libavformat/h263dec.c index 8afacad8b7..166ddb42e0 100644 --- a/libavformat/h263dec.c +++ b/libavformat/h263dec.c @@ -35,7 +35,7 @@ static int h263_probe(AVProbeData *p) for(i=0; ibuf_size; i++){ code = (code<<8) + p->buf[i]; if ((code & 0xfffffc0000) == 0x800000) { - src_fmt= (code>>2)&3; + src_fmt= (code>>2)&7; if( src_fmt != last_src_fmt && last_src_fmt>0 && last_src_fmt<6 && src_fmt<6) diff --git a/libavformat/hls.c b/libavformat/hls.c index 00c3cf01fb..065a759157 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -536,11 +536,13 @@ static int hls_read_header(AVFormatContext *s) /* Create new AVStreams for each stream in this variant */ for (j = 0; j < v->ctx->nb_streams; j++) { AVStream *st = avformat_new_stream(s, NULL); + AVStream *ist = v->ctx->streams[j]; if (!st) { ret = AVERROR(ENOMEM); goto fail; } st->id = i; + avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den); avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); if (v->bandwidth) av_dict_set(&st->metadata, "variant_bitrate", bitrate_str, diff --git a/libavformat/idcin.c b/libavformat/idcin.c index f1df00244f..c20c5f82a9 100644 --- a/libavformat/idcin.c +++ b/libavformat/idcin.c @@ -91,7 +91,7 @@ typedef struct IdcinDemuxContext { static int idcin_probe(AVProbeData *p) { - unsigned int number; + unsigned int number, sample_rate; /* * This is what you could call a "probabilistic" file check: id CIN @@ -120,18 +120,18 @@ static int idcin_probe(AVProbeData *p) return 0; /* check the audio sample rate */ - number = AV_RL32(&p->buf[8]); - if ((number != 0) && ((number < 8000) | (number > 48000))) + sample_rate = AV_RL32(&p->buf[8]); + if (sample_rate && (sample_rate < 8000 || sample_rate > 48000)) return 0; /* check the audio bytes/sample */ number = AV_RL32(&p->buf[12]); - if (number > 2) + if (number > 2 || sample_rate && !number) return 0; /* check the audio channels */ number = AV_RL32(&p->buf[16]); - if (number > 2) + if (number > 2 || sample_rate && !number) return 0; /* return half certainly since this check is a bit sketchy */ diff --git a/libavformat/iff.c b/libavformat/iff.c index 0055283b0e..b207990fc6 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -201,6 +201,8 @@ static int iff_read_header(AVFormatContext *s) break; case ID_CMAP: + if (data_size > INT_MAX - IFF_EXTRA_VIDEO_SIZE - FF_INPUT_BUFFER_PADDING_SIZE) + return AVERROR_INVALIDDATA; st->codec->extradata_size = data_size + IFF_EXTRA_VIDEO_SIZE; st->codec->extradata = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) @@ -323,6 +325,7 @@ static int iff_read_header(AVFormatContext *s) if (!st->codec->extradata) return AVERROR(ENOMEM); } + av_assert0(st->codec->extradata_size >= IFF_EXTRA_VIDEO_SIZE); buf = st->codec->extradata; bytestream_put_be16(&buf, IFF_EXTRA_VIDEO_SIZE); bytestream_put_byte(&buf, iff->bitmap_compression); diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c index 233eab8382..9dfb4e4fab 100644 --- a/libavformat/latmenc.c +++ b/libavformat/latmenc.c @@ -156,6 +156,15 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt) av_log(s, AV_LOG_ERROR, "ADTS header detected - ADTS will not be incorrectly muxed into LATM\n"); return AVERROR_INVALIDDATA; } + + if (!s->streams[0]->codec->extradata) { + if(pkt->size > 2 && pkt->data[0] == 0x56 && (pkt->data[1] >> 4) == 0xe && + (AV_RB16(pkt->data + 1) & 0x1FFF) + 3 == pkt->size) + return ff_raw_write_packet(s, pkt); + else + return AVERROR_INVALIDDATA; + } + if (pkt->size > 0x1fff) goto too_large; diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c index aa8edccb59..4ba9392aa0 100644 --- a/libavformat/libmodplug.c +++ b/libavformat/libmodplug.c @@ -347,6 +347,19 @@ static int modplug_read_seek(AVFormatContext *s, int stream_idx, int64_t ts, int return 0; } +static const char modplug_extensions[] = "669,abc,amf,ams,dbm,dmf,dsm,far,it,mdl,med,mid,mod,mt2,mtm,okt,psm,ptm,s3m,stm,ult,umx,xm,itgz,itr,itz,mdgz,mdr,mdz,s3gz,s3r,s3z,xmgz,xmr,xmz"; + +static int modplug_probe(AVProbeData *p) +{ + if (av_match_ext(p->filename, modplug_extensions)) { + if (p->buf_size < 16384) + return AVPROBE_SCORE_MAX/4-1; + else + return AVPROBE_SCORE_MAX/2; + } + return 0; +} + static const AVClass modplug_class = { .class_name = "ModPlug demuxer", .item_name = av_default_item_name, @@ -358,11 +371,11 @@ AVInputFormat ff_libmodplug_demuxer = { .name = "libmodplug", .long_name = NULL_IF_CONFIG_SMALL("ModPlug demuxer"), .priv_data_size = sizeof(ModPlugContext), + .read_probe = modplug_probe, .read_header = modplug_read_header, .read_packet = modplug_read_packet, .read_close = modplug_read_close, .read_seek = modplug_read_seek, - .extensions = "669,abc,amf,ams,dbm,dmf,dsm,far,it,mdl,med,mid,mod,mt2,mtm,okt,psm,ptm,s3m,stm,ult,umx,xm" - ",itgz,itr,itz,mdgz,mdr,mdz,s3gz,s3r,s3z,xmgz,xmr,xmz", // compressed mods + .extensions = modplug_extensions, .priv_class = &modplug_class, }; diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c index ccb9464c33..39eba00720 100644 --- a/libavformat/loasdec.c +++ b/libavformat/loasdec.c @@ -55,7 +55,6 @@ static int loas_probe(AVProbeData *p) if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; else if(max_frames>100)return AVPROBE_SCORE_MAX/2; else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; - else if(max_frames>=1) return 1; else return 0; } diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 64d0a459b4..1e92073921 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -21,6 +21,9 @@ #include "matroska.h" +/* If you add a tag here that is not in ff_codec_bmp_tags[] + or ff_codec_wav_tags[], add it also to additional_audio_tags[] + or additional_video_tags[] in matroskaenc.c */ const CodecTags ff_mkv_codec_tags[]={ {"A_AAC" , AV_CODEC_ID_AAC}, {"A_AC3" , AV_CODEC_ID_AC3}, @@ -111,7 +114,7 @@ const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREO_MODE_COUN "bottom_top", "top_bottom", "checkerboard_rl", - "checkerboard_lr" + "checkerboard_lr", "row_interleaved_rl", "row_interleaved_lr", "col_interleaved_rl", diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index a270f0dfc7..59130f1ffd 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1609,8 +1609,12 @@ static int matroska_read_header(AVFormatContext *s) } else if (!strcmp(track->codec_id, "V_QUICKTIME") && (track->codec_priv.size >= 86) && (track->codec_priv.data != NULL)) { - fourcc = AV_RL32(track->codec_priv.data); + fourcc = AV_RL32(track->codec_priv.data + 4); codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc); + if (ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(track->codec_priv.data))) { + fourcc = AV_RL32(track->codec_priv.data); + codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc); + } } else if (codec_id == AV_CODEC_ID_ALAC && track->codec_priv.size && track->codec_priv.size < INT_MAX-12) { /* Only ALAC's magic cookie is stored in Matroska's track headers. Create the "atom size", "tag", and "tag version" fields the @@ -1664,8 +1668,10 @@ static int matroska_read_header(AVFormatContext *s) avio_wl16(&b, 1); avio_wl16(&b, track->audio.channels); avio_wl16(&b, track->audio.bitdepth); + if (track->audio.out_samplerate < 0 || track->audio.out_samplerate > INT_MAX) + return AVERROR_INVALIDDATA; avio_wl32(&b, track->audio.out_samplerate); - avio_wl32(&b, matroska->ctx->duration * track->audio.out_samplerate); + avio_wl32(&b, av_rescale((matroska->duration * matroska->time_scale), track->audio.out_samplerate, AV_TIME_BASE * 1000)); } else if (codec_id == AV_CODEC_ID_RV10 || codec_id == AV_CODEC_ID_RV20 || codec_id == AV_CODEC_ID_RV30 || codec_id == AV_CODEC_ID_RV40) { extradata_offset = 26; @@ -1754,7 +1760,8 @@ static int matroska_read_header(AVFormatContext *s) av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, 1000000000, track->default_duration, 30000); #if FF_API_R_FRAME_RATE - st->r_frame_rate = st->avg_frame_rate; + if (st->avg_frame_rate.num < st->avg_frame_rate.den * 1000L) + st->r_frame_rate = st->avg_frame_rate; #endif } @@ -1873,6 +1880,7 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska, */ static void matroska_clear_queue(MatroskaDemuxContext *matroska) { + matroska->prev_pkt = NULL; if (matroska->packets) { int n; for (n = 0; n < matroska->num_packets; n++) { @@ -1885,10 +1893,10 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska) } static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, - int size, int type, + int* buf_size, int type, uint32_t **lace_buf, int *laces) { - int res = 0, n; + int res = 0, n, size = *buf_size; uint8_t *data = *buf; uint32_t *lace_size; @@ -1986,6 +1994,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf, *buf = data; *lace_buf = lace_size; + *buf_size = size; return res; } @@ -2157,6 +2166,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, uint32_t *lace_size = NULL; int n, flags, laces = 0; uint64_t num; + int trust_default_duration = 1; if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); @@ -2205,13 +2215,21 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, matroska->skip_to_keyframe = 0; } - res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1, + res = matroska_parse_laces(matroska, &data, &size, (flags & 0x06) >> 1, &lace_size, &laces); if (res) goto end; - if (!block_duration) + if (track->audio.samplerate == 8000) { + // If this is needed for more codecs, then add them here + if (st->codec->codec_id == AV_CODEC_ID_AC3) { + if(track->audio.samplerate != st->codec->sample_rate || !st->codec->frame_size) + trust_default_duration = 0; + } + } + + if (!block_duration && trust_default_duration) block_duration = track->default_duration * laces / matroska->time_scale; if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time)) @@ -2307,7 +2325,6 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska) } } - if (res < 0) matroska->done = 1; return res; } @@ -2377,7 +2394,6 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET); matroska->current_id = 0; while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { - matroska->prev_pkt = NULL; matroska_clear_queue(matroska); if (matroska_parse_cluster(matroska) < 0) break; @@ -2397,10 +2413,11 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE && !tracks[i].stream->discard != AVDISCARD_ALL) { index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD); - if (index_sub >= 0 - && st->index_entries[index_sub].pos < st->index_entries[index_min].pos - && st->index_entries[index].timestamp - st->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale) - index_min = index_sub; + while(index_sub >= 0 + && index_min >= 0 + && tracks[i].stream->index_entries[index_sub].pos < st->index_entries[index_min].pos + && st->index_entries[index].timestamp - tracks[i].stream->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale) + index_min--; } } diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 4fd30b86fb..ef10497e12 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -491,8 +491,18 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo if (qt_id) { if (!codec->codec_tag) codec->codec_tag = ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id); - if (codec->extradata_size) + if (codec->extradata_size) { + if ( ff_codec_get_id(ff_codec_movvideo_tags, codec->codec_tag) == codec->codec_id + && ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(codec->extradata+4)) != codec->codec_id + ) { + int i; + avio_wb32(dyn_cp, 0x5a + codec->extradata_size); + avio_wl32(dyn_cp, codec->codec_tag); + for(i=0; i<0x5a-8; i++) + avio_w8(dyn_cp, 0); + } avio_write(dyn_cp, codec->extradata, codec->extradata_size); + } } else { if (!codec->codec_tag) codec->codec_tag = ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id); @@ -793,6 +803,17 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme return 0; } +static int mkv_check_tag(AVDictionary *m) +{ + AVDictionaryEntry *t = NULL; + + while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) + if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode")) + return 1; + + return 0; +} + static int mkv_write_tags(AVFormatContext *s) { ebml_master tags = {0}; @@ -800,7 +821,7 @@ static int mkv_write_tags(AVFormatContext *s) ff_metadata_conv_ctx(s, ff_mkv_metadata_conv, NULL); - if (av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + if (mkv_check_tag(s->metadata)) { ret = mkv_write_tag(s, s->metadata, 0, 0, &tags); if (ret < 0) return ret; } @@ -808,7 +829,7 @@ static int mkv_write_tags(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; - if (!av_dict_get(st->metadata, "", 0, AV_DICT_IGNORE_SUFFIX)) + if (!mkv_check_tag(st->metadata)) continue; ret = mkv_write_tag(s, st->metadata, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1, &tags); @@ -818,7 +839,7 @@ static int mkv_write_tags(AVFormatContext *s) for (i = 0; i < s->nb_chapters; i++) { AVChapter *ch = s->chapters[i]; - if (!av_dict_get(ch->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) + if (!mkv_check_tag(ch->metadata)) continue; ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, ch->id, &tags); @@ -1325,6 +1346,32 @@ static int mkv_query_codec(enum AVCodecID codec_id, int std_compliance) return 0; } +const AVCodecTag additional_audio_tags[] = { + { AV_CODEC_ID_ALAC, 0XFFFFFFFF }, + { AV_CODEC_ID_EAC3, 0XFFFFFFFF }, + { AV_CODEC_ID_MLP, 0xFFFFFFFF }, + { AV_CODEC_ID_OPUS, 0xFFFFFFFF }, + { AV_CODEC_ID_PCM_S16BE, 0xFFFFFFFF }, + { AV_CODEC_ID_PCM_S24BE, 0xFFFFFFFF }, + { AV_CODEC_ID_PCM_S32BE, 0xFFFFFFFF }, + { AV_CODEC_ID_QDM2, 0xFFFFFFFF }, + { AV_CODEC_ID_RA_144, 0xFFFFFFFF }, + { AV_CODEC_ID_RA_288, 0xFFFFFFFF }, + { AV_CODEC_ID_COOK, 0xFFFFFFFF }, + { AV_CODEC_ID_TRUEHD, 0xFFFFFFFF }, + { AV_CODEC_ID_TTA, 0xFFFFFFFF }, + { AV_CODEC_ID_WAVPACK, 0xFFFFFFFF }, + { AV_CODEC_ID_NONE, 0xFFFFFFFF } +}; + +const AVCodecTag additional_video_tags[] = { + { AV_CODEC_ID_RV10, 0xFFFFFFFF }, + { AV_CODEC_ID_RV20, 0xFFFFFFFF }, + { AV_CODEC_ID_RV30, 0xFFFFFFFF }, + { AV_CODEC_ID_RV40, 0xFFFFFFFF }, + { AV_CODEC_ID_NONE, 0xFFFFFFFF } +}; + #if CONFIG_MATROSKA_MUXER AVOutputFormat ff_matroska_muxer = { .name = "matroska", @@ -1341,6 +1388,10 @@ AVOutputFormat ff_matroska_muxer = { .write_trailer = mkv_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT, + .codec_tag = (const AVCodecTag* const []){ + ff_codec_bmp_tags, ff_codec_wav_tags, + additional_audio_tags, additional_video_tags, 0 + }, .subtitle_codec = AV_CODEC_ID_SSA, .query_codec = mkv_query_codec, }; @@ -1377,5 +1428,8 @@ AVOutputFormat ff_matroska_audio_muxer = { .write_packet = mkv_write_packet, .write_trailer = mkv_write_trailer, .flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT, + .codec_tag = (const AVCodecTag* const []){ + ff_codec_wav_tags, additional_audio_tags, 0 + }, }; #endif diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c index d6e398200f..c71ecd67ef 100644 --- a/libavformat/mmsh.c +++ b/libavformat/mmsh.c @@ -309,14 +309,16 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim return 0; fail: av_freep(&stream_selection); - mmsh_close(h); av_dlog(NULL, "Connection failed with error %d\n", err); return err; } static int mmsh_open(URLContext *h, const char *uri, int flags) { - return mmsh_open_internal(h, uri, flags, 0, 0); + int ret = mmsh_open_internal(h, uri, flags, 0, 0); + if (ret < 0) + mmsh_close(h); + return ret; } static int handle_chunk_type(MMSHContext *mmsh) diff --git a/libavformat/mov.c b/libavformat/mov.c index 84565c8696..7d3c85b073 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -676,6 +676,9 @@ static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (atom.size < 16) return 0; + /* skip version and flags */ + avio_skip(pb, 4); + ff_mov_read_chan(c->fc, pb, st, atom.size - 4); return 0; @@ -778,14 +781,16 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) return mov_read_default(c, pb, atom); } -static void mov_metadata_creation_time(AVDictionary **metadata, time_t time) +static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time) { char buffer[32]; if (time) { struct tm *ptm; + time_t timet; if(time >= 2082844800) time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ - ptm = gmtime(&time); + timet = time; + ptm = gmtime(&timet); if (!ptm) return; strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm); av_dict_set(metadata, "creation_time", buffer, 0); @@ -799,7 +804,7 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) int version; char language[4] = {0}; unsigned lang; - time_t creation_time; + int64_t creation_time; if (c->fc->nb_streams < 1) return 0; @@ -834,7 +839,7 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) { - time_t creation_time; + int64_t creation_time; int version = avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ @@ -853,7 +858,7 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */ // set the AVCodecContext duration because the duration of individual tracks // may be inaccurate - if (c->time_scale > 0) + if (c->time_scale > 0 && !c->trex_data) c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale); avio_rb32(pb); /* preferred scale */ @@ -1664,6 +1669,8 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!entries) { sc->keyframe_absent = 1; + if (!st->need_parsing && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) + st->need_parsing = AVSTREAM_PARSE_HEADERS; return 0; } if (entries >= UINT_MAX / sizeof(int)) @@ -2000,6 +2007,11 @@ static void mov_build_index(MOVContext *mov, AVStream *st) rap_group_index++; } } + if (sc->keyframe_absent + && !sc->stps_count + && !rap_group_present + && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) + keyframe = 1; if (keyframe) distance = 0; sample_size = sc->alt_sample_size > 0 ? sc->alt_sample_size : sc->sample_sizes[current_sample]; @@ -2671,25 +2683,24 @@ static int mov_read_chan2(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -static int mov_read_tref(MOVContext *c, AVIOContext *pb, MOVAtom atom) +static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom) { - uint32_t i, size; + uint32_t i; MOVStreamContext *sc; if (c->fc->nb_streams < 1) return AVERROR_INVALIDDATA; sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data; - size = avio_rb32(pb); - if (size < 12) + if (atom.size < 4) return 0; - sc->trefs_count = (size - 4) / 8; + sc->trefs_count = atom.size / 4; sc->trefs = av_malloc(sc->trefs_count * sizeof(*sc->trefs)); if (!sc->trefs) return AVERROR(ENOMEM); - sc->tref_type = avio_rl32(pb); + sc->tref_type = atom.type; for (i = 0; i < sc->trefs_count; i++) sc->trefs[i] = avio_rb32(pb); return 0; @@ -2742,7 +2753,8 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('t','f','h','d'), mov_read_tfhd }, /* track fragment header */ { MKTAG('t','r','a','k'), mov_read_trak }, { MKTAG('t','r','a','f'), mov_read_default }, -{ MKTAG('t','r','e','f'), mov_read_tref }, +{ MKTAG('t','r','e','f'), mov_read_default }, +{ MKTAG('t','m','c','d'), mov_read_tmcd }, { MKTAG('c','h','a','p'), mov_read_chap }, { MKTAG('t','r','e','x'), mov_read_trex }, { MKTAG('t','r','u','n'), mov_read_trun }, diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 4b0a547e70..69400098f0 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -887,10 +887,11 @@ static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track) int i; for (i = 0; i < FF_ARRAY_ELEMS(mov_pix_fmt_tags); i++) { - if (track->enc->codec_tag == mov_pix_fmt_tags[i].tag && track->enc->pix_fmt == mov_pix_fmt_tags[i].pix_fmt) { + if (track->enc->pix_fmt == mov_pix_fmt_tags[i].pix_fmt) { tag = mov_pix_fmt_tags[i].tag; track->enc->bits_per_coded_sample = mov_pix_fmt_tags[i].bps; - break; + if (track->enc->codec_tag == mov_pix_fmt_tags[i].tag) + break; } } @@ -1096,13 +1097,17 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) mov_write_avcc_tag(pb, track); if(track->mode == MODE_IPOD) mov_write_uuid_tag_ipod(pb); - } else if (track->enc->field_order != AV_FIELD_UNKNOWN) - mov_write_fiel_tag(pb, track); - else if (track->enc->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0) + } else if (track->enc->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0) mov_write_dvc1_tag(pb, track); else if (track->vos_len > 0) mov_write_glbl_tag(pb, track); + if (track->enc->codec_id != AV_CODEC_ID_H264 && + track->enc->codec_id != AV_CODEC_ID_MPEG4 && + track->enc->codec_id != AV_CODEC_ID_DNXHD) + if (track->enc->field_order != AV_FIELD_UNKNOWN) + mov_write_fiel_tag(pb, track); + if (track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num && track->enc->sample_aspect_ratio.den != track->enc->sample_aspect_ratio.num) { mov_write_pasp_tag(pb, track); @@ -3080,6 +3085,14 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) memcpy(trk->vos_data, enc->extradata, trk->vos_len); } + if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && + (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { + if (!s->streams[pkt->stream_index]->nb_frames) { + av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); + return -1; + } + av_log(s, AV_LOG_WARNING, "aac bitstream error\n"); + } if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1) { /* from x264 or from bytestream h264 */ /* nal reformating needed */ @@ -3090,10 +3103,6 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) } else { size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size); } - } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && - (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { - av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); - return -1; } else { avio_write(pb, pkt->data, size); } @@ -3542,6 +3551,9 @@ static int mov_write_header(AVFormatContext *s) }else{ track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; } + if (st->codec->codec_id == AV_CODEC_ID_ILBC) { + track->audio_vbr = 1; + } if (track->mode != MODE_MOV && track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) { av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n", diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index ae549751e7..1d41c86789 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -120,6 +120,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}}; MPADecodeHeader c; int vbrtag_size = 0; + int is_cbr; v = avio_rb32(s->pb); if(ff_mpa_check_header(v) < 0) @@ -135,7 +136,8 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) /* Check for Xing / Info tag */ avio_skip(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1]); v = avio_rb32(s->pb); - if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) { + is_cbr = v == MKBETAG('I', 'n', 'f', 'o'); + if (v == MKBETAG('X', 'i', 'n', 'g') || is_cbr) { v = avio_rb32(s->pb); if(v & XING_FLAG_FRAMES) frames = avio_rb32(s->pb); @@ -180,7 +182,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) if(frames) st->duration = av_rescale_q(frames, (AVRational){spf, c.sample_rate}, st->time_base); - if(size && frames) + if (size && frames && !is_cbr) st->codec->bit_rate = av_rescale(size, 8 * c.sample_rate, frames * (int64_t)spf); return 0; diff --git a/libavformat/mpc.c b/libavformat/mpc.c index 3b818ed146..b9368112fb 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -151,7 +151,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) } c->curbits = (curbits + size2) & 0x1F; - if ((ret = av_new_packet(pkt, size)) < 0) + if ((ret = av_new_packet(pkt, size + 4)) < 0) return ret; pkt->data[0] = curbits; diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 54125ae9a2..38629c2749 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -497,7 +497,7 @@ static int mpegps_read_packet(AVFormatContext *s, if(st->discard >= AVDISCARD_ALL) goto skip; if (startcode >= 0xa0 && startcode <= 0xaf) { - if (lpcm_header_len == 6) { + if (lpcm_header_len == 6 && st->codec->codec_id == AV_CODEC_ID_MLP) { if (len < 6) goto skip; avio_skip(s->pb, 6); diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index c39cf45d7b..dd37f0f196 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1232,7 +1232,7 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, int section_le AVStream *st; if (ts->pids[pid]->es_id != mp4_descr[i].es_id) continue; - if (!(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES)) { + if (ts->pids[pid]->type != MPEGTS_PES) { av_log(s, AV_LOG_ERROR, "pid %x is not PES\n", pid); continue; } @@ -1578,12 +1578,18 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (sid == 0x0000) { /* NIT info */ } else { + MpegTSFilter *fil = ts->pids[pmt_pid]; program = av_new_program(ts->stream, sid); program->program_num = sid; program->pmt_pid = pmt_pid; - if (ts->pids[pmt_pid]) - mpegts_close_filter(ts, ts->pids[pmt_pid]); - mpegts_open_section_filter(ts, pmt_pid, pmt_cb, ts, 1); + if (fil) + if ( fil->type != MPEGTS_SECTION + || fil->pid != pmt_pid + || fil->u.section_filter.section_cb != pmt_cb) + mpegts_close_filter(ts, ts->pids[pmt_pid]); + + if (!ts->pids[pmt_pid]) + mpegts_open_section_filter(ts, pmt_pid, pmt_cb, ts, 1); add_pat_entry(ts, sid); add_pid_to_pmt(ts, sid, 0); //add pat pid to program add_pid_to_pmt(ts, sid, pmt_pid); diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index eba7312fbd..20b92e7ca9 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -255,7 +255,7 @@ static void mpegts_write_pat(AVFormatContext *s) data, q - data); } -static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) +static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) { MpegTSWrite *ts = s->priv_data; uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr; @@ -308,6 +308,10 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) stream_type = STREAM_TYPE_PRIVATE_DATA; break; } + + if (q - data > sizeof(data) - 32) + return AVERROR(EINVAL); + *q++ = stream_type; put16(&q, 0xe000 | ts_st->pid); desc_length_ptr = q; @@ -339,7 +343,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) len_ptr = q++; *len_ptr = 0; - for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) { + for (p = lang->value; next && *len_ptr < 255 / 4 * 4 && q - data < sizeof(data) - 4; p = next + 1) { next = strchr(p, ','); if (strlen(p) != 3 && (!next || next != p + 3)) continue; /* not a 3-letter code */ @@ -401,6 +405,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) } mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0, data, q - data); + return 0; } /* NOTE: str == NULL is accepted for an empty string */ diff --git a/libavformat/oggparseskeleton.c b/libavformat/oggparseskeleton.c index 4b02c838f2..79c018da66 100644 --- a/libavformat/oggparseskeleton.c +++ b/libavformat/oggparseskeleton.c @@ -37,6 +37,9 @@ static int skeleton_header(AVFormatContext *s, int idx) strcpy(st->codec->codec_name, "skeleton"); st->codec->codec_type = AVMEDIA_TYPE_DATA; + if ((os->flags & OGG_FLAG_EOS) && os->psize == 0) + return 1; + if (os->psize < 8) return -1; @@ -74,12 +77,16 @@ static int skeleton_header(AVFormatContext *s, int idx) target_idx = ogg_find_stream(ogg, AV_RL32(buf+12)); start_granule = AV_RL64(buf+36); - if (os->start_granule != OGG_NOGRANULE_VALUE) { - av_log_missing_feature(s, "multiple fisbone for the " - "same stream\n", 0); + if (target_idx < 0) { + av_log(s, AV_LOG_WARNING, "Serial number in fisbone doesn't match any stream\n"); return 1; } - if (target_idx >= 0 && start_granule != OGG_NOGRANULE_VALUE) { + os = ogg->streams + target_idx; + if (os->start_granule != OGG_NOGRANULE_VALUE) { + av_log(s, AV_LOG_WARNING, "Multiple fisbone for the same stream\n"); + return 1; + } + if (start_granule != OGG_NOGRANULE_VALUE) { os->start_granule = start_granule; } } diff --git a/libavformat/paf.c b/libavformat/paf.c index 8fe2ac5638..e695ace35e 100644 --- a/libavformat/paf.c +++ b/libavformat/paf.c @@ -231,10 +231,11 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) p->current_frame_block++; } - size = p->video_size - p->frames_offset_table[p->current_frame]; - if (size < 1) + if (p->frames_offset_table[p->current_frame] >= p->video_size) return AVERROR_INVALIDDATA; + size = p->video_size - p->frames_offset_table[p->current_frame]; + if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM); diff --git a/libavformat/riff.c b/libavformat/riff.c index 1c3411220e..06e69c49be 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -771,8 +771,13 @@ int ff_read_riff_info(AVFormatContext *s, int64_t size) chunk_code = avio_rl32(pb); chunk_size = avio_rl32(pb); if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) { - av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n"); - return AVERROR_INVALIDDATA; + avio_seek(pb, -9, SEEK_CUR); + chunk_code = avio_rl32(pb); + chunk_size = avio_rl32(pb); + if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) { + av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n"); + return AVERROR_INVALIDDATA; + } } chunk_size += (chunk_size & 1); diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 3cbf3f590f..238c74bfc0 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -107,13 +107,14 @@ static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned si return 0; } -static void rm_read_metadata(AVFormatContext *s, int wide) +static void rm_read_metadata(AVFormatContext *s, AVIOContext *pb, int wide) { char buf[1024]; int i; + for (i=0; ipb) : avio_r8(s->pb); - get_strl(s->pb, buf, sizeof(buf), len); + int len = wide ? avio_rb16(pb) : avio_r8(pb); + get_strl(pb, buf, sizeof(buf), len); av_dict_set(&s->metadata, ff_rm_metadata[i], buf, 0); } } @@ -143,7 +144,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, int header_size = avio_rb16(pb); int64_t startpos = avio_tell(pb); avio_skip(pb, 14); - rm_read_metadata(s, 0); + rm_read_metadata(s, pb, 0); if ((startpos + header_size) >= avio_tell(pb) + 2) { // fourcc (should always be "lpcJ") avio_r8(pb); @@ -290,7 +291,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, avio_r8(pb); avio_r8(pb); avio_r8(pb); - rm_read_metadata(s, 0); + rm_read_metadata(s, pb, 0); } } return 0; @@ -513,7 +514,7 @@ static int rm_read_header(AVFormatContext *s) flags = avio_rb16(pb); /* flags */ break; case MKTAG('C', 'O', 'N', 'T'): - rm_read_metadata(s, 1); + rm_read_metadata(s, pb, 1); break; case MKTAG('M', 'D', 'P', 'R'): st = avformat_new_stream(s, NULL); @@ -1014,6 +1015,18 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, return dts; } +static int rm_read_seek(AVFormatContext *s, int stream_index, + int64_t pts, int flags) +{ + RMDemuxContext *rm = s->priv_data; + + if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0) + return -1; + rm->audio_pkt_cnt = 0; + return 0; +} + + AVInputFormat ff_rm_demuxer = { .name = "rm", .long_name = NULL_IF_CONFIG_SMALL("RealMedia"), @@ -1023,6 +1036,7 @@ AVInputFormat ff_rm_demuxer = { .read_packet = rm_read_packet, .read_close = rm_read_close, .read_timestamp = rm_read_dts, + .read_seek = rm_read_seek, }; AVInputFormat ff_rdt_demuxer = { diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index b607d5b5e2..52395961fc 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -343,11 +343,11 @@ int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end) data++; break; } - if (data + size >= data_end || data + size < data) + if (size < 0 || size >= data_end - data) return -1; data += size; t = ff_amf_tag_size(data, data_end); - if (t < 0 || data + t >= data_end) + if (t < 0 || t >= data_end - data) return -1; data += t; } @@ -376,7 +376,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, int size = bytestream_get_be16(&data); if (!size) break; - if (data + size >= data_end || data + size < data) + if (size < 0 || size >= data_end - data) return -1; data += size; if (size == namelen && !memcmp(data-size, name, namelen)) { @@ -397,7 +397,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, return 0; } len = ff_amf_tag_size(data, data_end); - if (len < 0 || data + len >= data_end || data + len < data) + if (len < 0 || len >= data_end - data) return -1; data += len; } @@ -427,7 +427,7 @@ static const char* rtmp_packet_type(int type) static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *data_end) { - int size; + unsigned int size; char buf[1024]; if (data >= data_end) @@ -446,7 +446,7 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d } else { size = bytestream_get_be32(&data); } - size = FFMIN(size, 1023); + size = FFMIN(size, sizeof(buf) - 1); memcpy(buf, data, size); buf[size] = 0; av_log(ctx, AV_LOG_DEBUG, " string '%s'\n", buf); @@ -459,22 +459,21 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d case AMF_DATA_TYPE_OBJECT: av_log(ctx, AV_LOG_DEBUG, " {\n"); for (;;) { - int size = bytestream_get_be16(&data); int t; - memcpy(buf, data, size); - buf[size] = 0; + size = bytestream_get_be16(&data); + av_strlcpy(buf, data, FFMIN(sizeof(buf), size + 1)); if (!size) { av_log(ctx, AV_LOG_DEBUG, " }\n"); data++; break; } - if (data + size >= data_end || data + size < data) + if (size >= data_end - data) return; data += size; av_log(ctx, AV_LOG_DEBUG, " %s: ", buf); ff_amf_tag_contents(ctx, data, data_end); t = ff_amf_tag_size(data, data_end); - if (t < 0 || data + t >= data_end) + if (t < 0 || t >= data_end - data) return; data += t; } diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 518e7b290a..f2b3d5fd1c 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -48,7 +48,7 @@ //#define DEBUG -#define APP_MAX_LENGTH 128 +#define APP_MAX_LENGTH 1024 #define PLAYPATH_MAX_LENGTH 256 #define TCURL_MAX_LENGTH 512 #define FLASHVER_MAX_LENGTH 64 @@ -305,7 +305,7 @@ static int gen_connect(URLContext *s, RTMPContext *rt) int ret; if ((ret = ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, - 0, 4096)) < 0) + 0, 4096 + APP_MAX_LENGTH)) < 0) return ret; p = pkt.data; @@ -1793,7 +1793,7 @@ static int handle_invoke(URLContext *s, RTMPPacket *pkt) !memcmp(pkt->data, "\002\000\007publish", 10) || !memcmp(pkt->data, "\002\000\010_checkbw", 11) || !memcmp(pkt->data, "\002\000\014createStream", 15)) { - if (ret = send_invoke_response(s, pkt) < 0) + if ((ret = send_invoke_response(s, pkt)) < 0) return ret; } @@ -2156,16 +2156,20 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) fname = strchr(p + 1, '/'); if (!fname || (c && c < fname)) { fname = p + 1; - av_strlcpy(rt->app, path + 1, p - path); + av_strlcpy(rt->app, path + 1, FFMIN(p - path, APP_MAX_LENGTH)); } else { fname++; - av_strlcpy(rt->app, path + 1, fname - path - 1); + av_strlcpy(rt->app, path + 1, FFMIN(fname - path - 1, APP_MAX_LENGTH)); } } } if (old_app) { // The name of application has been defined by the user, override it. + if (strlen(old_app) >= APP_MAX_LENGTH) { + ret = AVERROR(EINVAL); + goto fail; + } av_free(rt->app); rt->app = old_app; } diff --git a/libavformat/rtpenc_h264.c b/libavformat/rtpenc_h264.c index 68f497590b..b6c16e17d8 100644 --- a/libavformat/rtpenc_h264.c +++ b/libavformat/rtpenc_h264.c @@ -31,14 +31,14 @@ static const uint8_t *avc_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size) { - int res = 0; + unsigned int res = 0; if (end - start < nal_length_size) return NULL; while (nal_length_size--) res = (res << 8) | *start++; - if (start + res > end || res < 0 || start + res < start) + if (res > end - start) return NULL; return start + res; diff --git a/libavformat/smacker.c b/libavformat/smacker.c index cf1ab858d8..7d2cccdaeb 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -269,7 +269,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) } else if(t & 0x40){ /* copy with offset */ off = avio_r8(s->pb); j = (t & 0x3F) + 1; - if (off + j > 0xff) { + if (off + j - 1 > 0xff) { av_log(s, AV_LOG_ERROR, "Invalid palette update, offset=%d length=%d extends beyond palette size\n", off, j); diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index 86ea6dec9e..ee1b5960aa 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -72,7 +72,7 @@ static int zlib_refill(void *opaque, uint8_t *buf, int buf_size) retry: if (!z->avail_in) { int n = avio_read(s->pb, swf->zbuf_in, ZBUF_SIZE); - if (n <= 0) + if (n < 0) return n; z->next_in = swf->zbuf_in; z->avail_in = n; @@ -153,6 +153,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) tag = get_swf_tag(pb, &len); if (tag < 0) return tag; + if (len < 0) { + av_log(s, AV_LOG_ERROR, "invalid tag length: %d\n", len); + return AVERROR_INVALIDDATA; + } if (tag == TAG_VIDEOSTREAM) { int ch_id = avio_rl16(pb); len -= 2; @@ -208,7 +212,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) { frame = avio_rl16(pb); - if ((res = av_get_packet(pb, pkt, len-2)) < 0) + len -= 2; + if (len <= 0) + goto skip; + if ((res = av_get_packet(pb, pkt, len)) < 0) return res; pkt->pos = pos; pkt->pts = frame; @@ -222,9 +229,14 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) { if (st->codec->codec_id == AV_CODEC_ID_MP3) { avio_skip(pb, 4); - if ((res = av_get_packet(pb, pkt, len-4)) < 0) + len -= 4; + if (len <= 0) + goto skip; + if ((res = av_get_packet(pb, pkt, len)) < 0) return res; } else { // ADPCM, PCM + if (len <= 0) + goto skip; if ((res = av_get_packet(pb, pkt, len)) < 0) return res; } @@ -250,7 +262,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) st = vst; } avio_rl16(pb); /* BITMAP_ID */ - if ((res = av_new_packet(pkt, len-2)) < 0) + len -= 2; + if (len < 4) + goto skip; + if ((res = av_new_packet(pkt, len)) < 0) return res; avio_read(pb, pkt->data, 4); if (AV_RB32(pkt->data) == 0xffd8ffd9 || @@ -267,6 +282,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) return pkt->size; } skip: + len = FFMAX(0, len); avio_skip(pb, len); } } diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index 4a5be12783..86618d3968 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -188,6 +188,10 @@ static int swf_write_header(AVFormatContext *s) AVCodecContext *enc = s->streams[i]->codec; if (enc->codec_type == AVMEDIA_TYPE_AUDIO) { if (enc->codec_id == AV_CODEC_ID_MP3) { + if (!enc->frame_size) { + av_log(s, AV_LOG_ERROR, "audio frame size not set\n"); + return -1; + } swf->audio_enc = enc; swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE); if (!swf->audio_fifo) @@ -449,7 +453,7 @@ static int swf_write_audio(AVFormatContext *s, } av_fifo_generic_write(swf->audio_fifo, buf, size, NULL); - swf->sound_samples += av_get_audio_frame_duration(enc, size); + swf->sound_samples += enc->frame_size; /* if audio only stream make sure we add swf frames */ if (!swf->video_enc) diff --git a/libavformat/utils.c b/libavformat/utils.c index 05c4b7f5cc..fd9a2d6fe6 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -459,7 +459,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, { AVProbeData pd = { filename ? filename : "", NULL, -offset }; unsigned char *buf = NULL; - int ret = 0, probe_size; + int ret = 0, probe_size, buf_offset = 0; if (!max_probe_size) { max_probe_size = PROBE_BUF_MAX; @@ -499,7 +499,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, score = 0; ret = 0; /* error was end of file, nothing read */ } - pd.buf_size += ret; + pd.buf_size = buf_offset += ret; pd.buf = &buf[offset]; memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE); @@ -642,7 +642,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma goto fail; if (id3v2_extra_meta) { - if (!strcmp(s->iformat->name, "mp3")) { + if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac")) { if((ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0) goto fail; } else @@ -676,6 +676,21 @@ fail: /*******************************************************/ +static void force_codec_ids(AVFormatContext *s, AVStream *st) +{ + switch(st->codec->codec_type){ + case AVMEDIA_TYPE_VIDEO: + if(s->video_codec_id) st->codec->codec_id= s->video_codec_id; + break; + case AVMEDIA_TYPE_AUDIO: + if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id; + break; + case AVMEDIA_TYPE_SUBTITLE: + if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id; + break; + } +} + static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) { if(st->request_probe>0){ @@ -716,25 +731,11 @@ no_packet: }else av_log(s, AV_LOG_WARNING, "probed stream %d failed\n", st->index); } + force_codec_ids(s, st); } } } -static void force_codec_ids(AVFormatContext *s, AVStream *st) -{ - switch(st->codec->codec_type){ - case AVMEDIA_TYPE_VIDEO: - if(s->video_codec_id) st->codec->codec_id= s->video_codec_id; - break; - case AVMEDIA_TYPE_AUDIO: - if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id; - break; - case AVMEDIA_TYPE_SUBTITLE: - if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id; - break; - } -} - int ff_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, i; @@ -845,6 +846,13 @@ static int get_audio_frame_size(AVCodecContext *enc, int size, int mux) if (enc->frame_size > 1) return enc->frame_size; + //For WMA we currently have no other means to calculate duration thus we + //do it here by assuming CBR, which is true for all known cases. + if(!mux && enc->bit_rate>0 && size>0 && enc->sample_rate>0 && enc->block_align>1) { + if (enc->codec_id == AV_CODEC_ID_WMAV1 || enc->codec_id == AV_CODEC_ID_WMAV2) + return ((int64_t)size * 8 * enc->sample_rate) / enc->bit_rate; + } + return -1; } @@ -1098,12 +1106,14 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if (pkt->dts != AV_NOPTS_VALUE) { // got DTS from the stream, update reference timestamp st->reference_dts = pkt->dts - pc->dts_ref_dts_delta * num / den; - pkt->pts = pkt->dts + pc->pts_dts_delta * num / den; } else if (st->reference_dts != AV_NOPTS_VALUE) { // compute DTS based on reference timestamp pkt->dts = st->reference_dts + pc->dts_ref_dts_delta * num / den; - pkt->pts = pkt->dts + pc->pts_dts_delta * num / den; } + + if (st->reference_dts != AV_NOPTS_VALUE && pkt->pts == AV_NOPTS_VALUE) + pkt->pts = pkt->dts + pc->pts_dts_delta * num / den; + if (pc->dts_sync_point > 0) st->reference_dts = pkt->dts; // new reference } @@ -1404,6 +1414,9 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) st->skip_to_keyframe = 0; if (st->skip_to_keyframe) { av_free_packet(&cur_pkt); + if (got_packet) { + *pkt = cur_pkt; + } got_packet = 0; } } @@ -1475,7 +1488,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) } /* read packet from packet buffer, if there is data */ - if (!(next_pkt->pts == AV_NOPTS_VALUE && + st = s->streams[next_pkt->stream_index]; + if (!(next_pkt->pts == AV_NOPTS_VALUE && st->discard < AVDISCARD_ALL && next_pkt->dts != AV_NOPTS_VALUE && !eof)) { ret = read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt); @@ -2689,9 +2703,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) goto find_stream_info_err; } - read_size += pkt->size; - st = ic->streams[pkt->stream_index]; + if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC)) + read_size += pkt->size; + if (pkt->dts != AV_NOPTS_VALUE && st->codec_info_nb_frames > 1) { /* check for non-increasing dts */ if (st->info->fps_last_dts != AV_NOPTS_VALUE && @@ -3056,6 +3071,7 @@ void ff_free_stream(AVFormatContext *s, AVStream *st){ av_freep(&st->codec); av_freep(&st->priv_data); av_freep(&st->info); + av_freep(&st->probe_data.buf); av_freep(&s->streams[ --s->nb_streams ]); } diff --git a/libavformat/wav.c b/libavformat/wav.c index f58bcb32ad..4648486c00 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -527,8 +527,7 @@ static int wav_read_header(AVFormatContext *s) } switch (list_type) { case MKTAG('I', 'N', 'F', 'O'): - if ((ret = ff_read_riff_info(s, size - 4)) < 0) - return ret; + ff_read_riff_info(s, size - 4); } break; } @@ -547,8 +546,15 @@ break_loop: avio_seek(pb, data_ofs, SEEK_SET); - if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id)) - sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id)); + if (!sample_count || av_get_exact_bits_per_sample(st->codec->codec_id) > 0) + if ( st->codec->channels + && data_size + && av_get_bits_per_sample(st->codec->codec_id) + && wav->data_end <= avio_size(pb)) + sample_count = (data_size << 3) + / + (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id)); + if (sample_count) st->duration = sample_count; diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 319b986ab4..28eba65f76 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -413,6 +413,7 @@ static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length) char description[1024]; unsigned int filesize; AVStream *st; + int ret; int64_t pos = avio_tell(pb); avio_get_str16le(pb, INT_MAX, mime, sizeof(mime)); @@ -429,13 +430,14 @@ static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length) if (!st) goto done; av_dict_set(&st->metadata, "title", description, 0); + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_MJPEG; - st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT; - st->codec->extradata = av_mallocz(filesize); - if (!st->codec->extradata) + ret = av_get_packet(pb, &st->attached_pic, filesize); + if (ret < 0) goto done; - st->codec->extradata_size = filesize; - avio_read(pb, st->codec->extradata, filesize); + st->attached_pic.stream_index = st->index; + st->attached_pic.flags |= AV_PKT_FLAG_KEY; + st->disposition |= AV_DISPOSITION_ATTACHED_PIC; done: avio_seek(pb, pos + length, SEEK_SET); } diff --git a/libavutil/cpu.c b/libavutil/cpu.c index f651cab64b..be743ee088 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -23,6 +23,24 @@ static int flags, checked; void av_force_cpu_flags(int arg){ + if ( (arg & ( AV_CPU_FLAG_3DNOW | + AV_CPU_FLAG_3DNOWEXT | + AV_CPU_FLAG_SSE | + AV_CPU_FLAG_SSE2 | + AV_CPU_FLAG_SSE2SLOW | + AV_CPU_FLAG_SSE3 | + AV_CPU_FLAG_SSE3SLOW | + AV_CPU_FLAG_SSSE3 | + AV_CPU_FLAG_SSE4 | + AV_CPU_FLAG_SSE42 | + AV_CPU_FLAG_AVX | + AV_CPU_FLAG_XOP | + AV_CPU_FLAG_FMA4 )) + && !(arg & AV_CPU_FLAG_MMX)) { + av_log(NULL, AV_LOG_WARNING, "MMX implied by specified flags\n"); + arg |= AV_CPU_FLAG_MMX; + } + flags = arg; checked = arg != -1; } diff --git a/libavutil/intfloat_readwrite.c b/libavutil/intfloat_readwrite.c index 2998229e49..142331dac1 100644 --- a/libavutil/intfloat_readwrite.c +++ b/libavutil/intfloat_readwrite.c @@ -26,6 +26,7 @@ */ #include +#include "common.h" #include "mathematics.h" #include "intfloat_readwrite.h" @@ -88,7 +89,7 @@ AVExtFloat av_dbl2ext(double d){ ext.mantissa[i] = m>>(56-(i<<3)); } else if (f != 0.0) { ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff; - if (f != INFINITY) + if (!isinf(f)) ext.mantissa[0] = ~0; } if (d < 0) diff --git a/libavutil/log.c b/libavutil/log.c index 1bae1b2165..f7873a3039 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -100,6 +100,9 @@ static int use_color = -1; #undef fprintf static void colored_fputs(int level, const char *str) { + if (!*str) + return; + if (use_color < 0) { #if defined(_WIN32) && !defined(__MINGW32CE__) CONSOLE_SCREEN_BUFFER_INFO con_info; @@ -177,7 +180,7 @@ static void format_line(void *ptr, int level, const char *fmt, va_list vl, if (parent && *parent) { snprintf(part[0], part_size, "[%s @ %p] ", (*parent)->item_name(parent), parent); - if(type) type[0] = get_category(((uint8_t *) ptr) + avc->parent_log_context_offset); + if(type) type[0] = get_category(parent); } } snprintf(part[1], part_size, "[%s @ %p] ", diff --git a/libavutil/lzo.c b/libavutil/lzo.c index 3642308100..f6c632944a 100644 --- a/libavutil/lzo.c +++ b/libavutil/lzo.c @@ -62,7 +62,13 @@ static inline int get_byte(LZOContext *c) { static inline int get_len(LZOContext *c, int x, int mask) { int cnt = x & mask; if (!cnt) { - while (!(x = get_byte(c))) cnt += 255; + while (!(x = get_byte(c))) { + if (cnt >= INT_MAX - 1000) { + c->error |= AV_LZO_ERROR; + break; + } + cnt += 255; + } cnt += mask + x; } return cnt; @@ -118,10 +124,10 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); * cnt > back is valid, this will copy the bytes we just copied, * thus creating a repeating pattern with a period length of back. */ -static inline void copy_backptr(LZOContext *c, int back, int cnt) { - register const uint8_t *src = &c->out[-back]; - register uint8_t *dst = c->out; - if (src < c->out_start || src > dst) { +static inline void copy_backptr(LZOContext *c, int back, int cnt) +{ + register uint8_t *dst = c->out; + if (dst - c->out_start < back) { c->error |= AV_LZO_INVALID_BACKPTR; return; } diff --git a/libavutil/opt.c b/libavutil/opt.c index 0957281076..76e8c90b18 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -236,7 +236,7 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons int av_opt_set(void *obj, const char *name, const char *val, int search_flags) { - int ret; + int ret = 0; void *dst, *target_obj; const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); if (!o || !target_obj) diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c index a03648e200..2b5a378c76 100644 --- a/libavutil/samplefmt.c +++ b/libavutil/samplefmt.c @@ -135,6 +135,8 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, /* auto-select alignment if not specified */ if (!align) { + if (nb_samples > INT_MAX - 31) + return AVERROR(EINVAL); align = 1; nb_samples = FFALIGN(nb_samples, 32); } diff --git a/libavutil/tree.c b/libavutil/tree.c index 4206539c37..207b6a15f8 100644 --- a/libavutil/tree.c +++ b/libavutil/tree.c @@ -205,13 +205,13 @@ int main (void) av_lfg_init(&prng, 1); for (i = 0; i < 10000; i++) { - int j = av_lfg_get(&prng) % 86294; + intptr_t j = av_lfg_get(&prng) % 86294; if (check(root) > 999) { av_log(NULL, AV_LOG_ERROR, "FATAL error %d\n", i); print(root, 0); return -1; } - av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j); + av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", (int)j); if (!node) node = av_mallocz(av_tree_node_size); av_tree_insert(&root, (void *) (j + 1), cmp, &node); @@ -219,7 +219,7 @@ int main (void) j = av_lfg_get(&prng) % 86294; { AVTreeNode *node2 = NULL; - av_log(NULL, AV_LOG_ERROR, "removing %4d\n", j); + av_log(NULL, AV_LOG_ERROR, "removing %4d\n", (int)j); av_tree_insert(&root, (void *) (j + 1), cmp, &node2); k = av_tree_find(root, (void *) (j + 1), cmp, NULL); if (k) diff --git a/libswresample/dither.c b/libswresample/dither.c index 79113f4c23..28cfbdd501 100644 --- a/libswresample/dither.c +++ b/libswresample/dither.c @@ -24,7 +24,7 @@ void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt) { double scale = 0; #define TMP_EXTRA 2 - double *tmp = av_malloc((len + TMP_EXTRA) * sizeof(double)); + double *tmp = av_malloc_array(len + TMP_EXTRA, sizeof(double)); int i; out_fmt = av_get_packed_sample_fmt(out_fmt); diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 72da438e6c..0d568afdbe 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -103,9 +103,6 @@ static int even(int64_t layout){ } static int clean_layout(SwrContext *s, int64_t layout){ - if((layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == AV_CH_LAYOUT_STEREO_DOWNMIX) - return AV_CH_LAYOUT_STEREO; - if(layout && layout != AV_CH_FRONT_CENTER && !(layout&(layout-1))) { char buf[128]; av_get_channel_layout_string(buf, sizeof(buf), -1, layout); @@ -143,13 +140,24 @@ av_cold static int auto_matrix(SwrContext *s) const int matrix_encoding = s->matrix_encoding; in_ch_layout = clean_layout(s, s->in_ch_layout); + out_ch_layout = clean_layout(s, s->out_ch_layout); + + if( out_ch_layout == AV_CH_LAYOUT_STEREO_DOWNMIX + && (in_ch_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == 0 + ) + out_ch_layout = AV_CH_LAYOUT_STEREO; + + if( in_ch_layout == AV_CH_LAYOUT_STEREO_DOWNMIX + && (out_ch_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == 0 + ) + in_ch_layout = AV_CH_LAYOUT_STEREO; + if(!sane_layout(in_ch_layout)){ av_get_channel_layout_string(buf, sizeof(buf), -1, s->in_ch_layout); av_log(s, AV_LOG_ERROR, "Input channel layout '%s' is not supported\n", buf); return AVERROR(EINVAL); } - out_ch_layout = clean_layout(s, s->out_ch_layout); if(!sane_layout(out_ch_layout)){ av_get_channel_layout_string(buf, sizeof(buf), -1, s->out_ch_layout); av_log(s, AV_LOG_ERROR, "Output channel layout '%s' is not supported\n", buf); diff --git a/libswresample/rematrix_template.c b/libswresample/rematrix_template.c index 627bf1f6fc..61d3fe9cc9 100644 --- a/libswresample/rematrix_template.c +++ b/libswresample/rematrix_template.c @@ -18,9 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -typedef void (RENAME(mix_any_func_type))(SAMPLE **out, const SAMPLE **in1, COEFF *coeffp, int len); +typedef void (RENAME(mix_any_func_type))(SAMPLE **out, const SAMPLE **in1, COEFF *coeffp, integer len); -static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, COEFF *coeffp, int index1, int index2, int len){ +static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, COEFF *coeffp, integer index1, integer index2, integer len){ int i; COEFF coeff1 = coeffp[index1]; COEFF coeff2 = coeffp[index2]; @@ -29,14 +29,14 @@ static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, COEF out[i] = R(coeff1*in1[i] + coeff2*in2[i]); } -static void RENAME(copy)(SAMPLE *out, const SAMPLE *in, COEFF *coeffp, int index, int len){ +static void RENAME(copy)(SAMPLE *out, const SAMPLE *in, COEFF *coeffp, integer index, integer len){ int i; COEFF coeff = coeffp[index]; for(i=0; i INT32_MAX/256) { + av_log(NULL, AV_LOG_ERROR, "Filter length too large\n"); + goto error; + } + c->phase_shift = phase_shift; c->phase_mask = phase_count - 1; c->linear = linear; diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 5d02aafb49..4becb0724d 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -223,6 +223,16 @@ av_cold int swr_init(struct SwrContext *s){ s->flushed = 0; + if(av_get_channel_layout_nb_channels(s-> in_ch_layout) > SWR_CH_MAX) { + av_log(s, AV_LOG_WARNING, "Input channel layout 0x%"PRIx64" is invalid or unsupported.\n", s-> in_ch_layout); + s->in_ch_layout = 0; + } + + if(av_get_channel_layout_nb_channels(s->out_ch_layout) > SWR_CH_MAX) { + av_log(s, AV_LOG_WARNING, "Output channel layout 0x%"PRIx64" is invalid or unsupported.\n", s->out_ch_layout); + s->out_ch_layout = 0; + } + if(s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){ av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt); return AVERROR(EINVAL); @@ -770,7 +780,7 @@ int64_t swr_next_pts(struct SwrContext *s, int64_t pts){ if(s->min_compensation >= FLT_MAX) { return (s->outpts = pts - swr_get_delay(s, s->in_sample_rate * (int64_t)s->out_sample_rate)); } else { - int64_t delta = pts - swr_get_delay(s, s->in_sample_rate * (int64_t)s->out_sample_rate) - s->outpts; + int64_t delta = pts - swr_get_delay(s, s->in_sample_rate * (int64_t)s->out_sample_rate) - s->outpts + s->drop_output*(int64_t)s->in_sample_rate; double fdelta = delta /(double)(s->in_sample_rate * (int64_t)s->out_sample_rate); if(fabs(fdelta) > s->min_compensation) { diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index ab17602c64..38b18d9d7e 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -23,13 +23,20 @@ #include "swresample.h" #include "libavutil/audioconvert.h" +#include "config.h" #define SQRT3_2 1.22474487139158904909 /* sqrt(3/2) */ -typedef void (mix_1_1_func_type)(void *out, const void *in, void *coeffp, int index, int len); -typedef void (mix_2_1_func_type)(void *out, const void *in1, const void *in2, void *coeffp, int index1, int index2, int len); +#if ARCH_X86_64 +typedef int64_t integer; +#else +typedef int integer; +#endif -typedef void (mix_any_func_type)(uint8_t **out, const uint8_t **in1, void *coeffp, int len); +typedef void (mix_1_1_func_type)(void *out, const void *in, void *coeffp, integer index, integer len); +typedef void (mix_2_1_func_type)(void *out, const void *in1, const void *in2, void *coeffp, integer index1, integer index2, integer len); + +typedef void (mix_any_func_type)(uint8_t **out, const uint8_t **in1, void *coeffp, integer len); typedef struct AudioData{ uint8_t *ch[SWR_CH_MAX]; ///< samples buffer per channel diff --git a/libswresample/x86/audio_convert.asm b/libswresample/x86/audio_convert.asm index 29701a594c..854f8e4e56 100644 --- a/libswresample/x86/audio_convert.asm +++ b/libswresample/x86/audio_convert.asm @@ -196,7 +196,12 @@ cglobal %2_to_%1_%3, 3, 3, 6, dst, src, len add lenq, 2*mmsize/(1<<%4) %endif jl .next +%if mmsize == 8 + emms + RET +%else REP_RET +%endif %endmacro %macro PACK_6CH 5-7 diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 9180f2eb5c..375bc559c4 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -631,6 +631,9 @@ static rgbConvFn findRgbConvFn(SwsContext *c) } } + if ((dstFormat == PIX_FMT_RGB32_1 || dstFormat == PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0) + return NULL; + return conv; } diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index 102a4e6f22..960f73cc6e 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -261,7 +261,8 @@ static void yuv2yuvX_sse3(const int16_t *filter, int filterSize, "jb 1b \n\t"\ :: "g" (filter), "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset) - : "%"REG_d, "%"REG_S, "%"REG_c + : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" , "%xmm4" , "%xmm5" , "%xmm7" ,) + "%"REG_d, "%"REG_S, "%"REG_c ); } #endif diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 370a0ebe1b..f89902bc59 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -321,7 +321,7 @@ static void RENAME(yuv2yuvX)(const int16_t *filter, int filterSize, MOVNTQ( q3, 24(dst, index, 4))\ \ "add $8, "#index" \n\t"\ - "cmp "#dstw", "#index" \n\t"\ + "cmp "dstw", "#index" \n\t"\ " jb 1b \n\t" #define WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) @@ -347,13 +347,13 @@ static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter, "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" "packuswb %%mm7, %%mm1 \n\t" - WRITEBGR32(%4, %5, %%REGa, %%mm3, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm2, %%mm6) + WRITEBGR32(%4, "%5", %%REGa, %%mm3, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm2, %%mm6) YSCALEYUV2PACKEDX_END } else { YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX "pcmpeqd %%mm7, %%mm7 \n\t" - WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + WRITEBGR32(%4, "%5", %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) YSCALEYUV2PACKEDX_END } } @@ -376,13 +376,13 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" "packuswb %%mm7, %%mm1 \n\t" - WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) + WRITEBGR32(%4, "%5", %%REGa, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) YSCALEYUV2PACKEDX_END } else { YSCALEYUV2PACKEDX YSCALEYUV2RGBX "pcmpeqd %%mm7, %%mm7 \n\t" - WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + WRITEBGR32(%4, "%5", %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) YSCALEYUV2PACKEDX_END } } @@ -411,7 +411,7 @@ static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter, MOVNTQ(%%mm1, 8(dst, index, 2))\ \ "add $8, "#index" \n\t"\ - "cmp "#dstw", "#index" \n\t"\ + "cmp "dstw", "#index" \n\t"\ " jb 1b \n\t" #define WRITERGB16(dst, dstw, index) REAL_WRITERGB16(dst, dstw, index) @@ -435,7 +435,7 @@ static void RENAME(yuv2rgb565_X_ar)(SwsContext *c, const int16_t *lumFilter, "paddusb "GREEN_DITHER"(%0), %%mm4\n\t" "paddusb "RED_DITHER"(%0), %%mm5\n\t" #endif - WRITERGB16(%4, %5, %%REGa) + WRITERGB16(%4, "%5", %%REGa) YSCALEYUV2PACKEDX_END } @@ -459,7 +459,7 @@ static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter, "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t" "paddusb "RED_DITHER"(%0), %%mm5 \n\t" #endif - WRITERGB16(%4, %5, %%REGa) + WRITERGB16(%4, "%5", %%REGa) YSCALEYUV2PACKEDX_END } @@ -488,7 +488,7 @@ static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter, MOVNTQ(%%mm1, 8(dst, index, 2))\ \ "add $8, "#index" \n\t"\ - "cmp "#dstw", "#index" \n\t"\ + "cmp "dstw", "#index" \n\t"\ " jb 1b \n\t" #define WRITERGB15(dst, dstw, index) REAL_WRITERGB15(dst, dstw, index) @@ -512,7 +512,7 @@ static void RENAME(yuv2rgb555_X_ar)(SwsContext *c, const int16_t *lumFilter, "paddusb "GREEN_DITHER"(%0), %%mm4\n\t" "paddusb "RED_DITHER"(%0), %%mm5\n\t" #endif - WRITERGB15(%4, %5, %%REGa) + WRITERGB15(%4, "%5", %%REGa) YSCALEYUV2PACKEDX_END } @@ -536,7 +536,7 @@ static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter, "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t" "paddusb "RED_DITHER"(%0), %%mm5 \n\t" #endif - WRITERGB15(%4, %5, %%REGa) + WRITERGB15(%4, "%5", %%REGa) YSCALEYUV2PACKEDX_END } @@ -590,7 +590,7 @@ static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter, "add $24, "#dst" \n\t"\ \ "add $8, "#index" \n\t"\ - "cmp "#dstw", "#index" \n\t"\ + "cmp "dstw", "#index" \n\t"\ " jb 1b \n\t" #define WRITEBGR24MMX2(dst, dstw, index) \ @@ -638,7 +638,7 @@ static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter, "add $24, "#dst" \n\t"\ \ "add $8, "#index" \n\t"\ - "cmp "#dstw", "#index" \n\t"\ + "cmp "dstw", "#index" \n\t"\ " jb 1b \n\t" #if COMPILE_TEMPLATE_MMXEXT @@ -665,7 +665,7 @@ static void RENAME(yuv2bgr24_X_ar)(SwsContext *c, const int16_t *lumFilter, "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize "add %4, %%"REG_c" \n\t" - WRITEBGR24(%%REGc, %5, %%REGa) + WRITEBGR24(%%REGc, "%5", %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW_reg), "m"(uv_off) @@ -689,7 +689,7 @@ static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter, "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c" \n\t" //FIXME optimize "add %4, %%"REG_c" \n\t" - WRITEBGR24(%%REGc, %5, %%REGa) + WRITEBGR24(%%REGc, "%5", %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW_reg), "m"(uv_off) @@ -710,7 +710,7 @@ static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter, MOVNTQ(%%mm7, 8(dst, index, 2))\ \ "add $8, "#index" \n\t"\ - "cmp "#dstw", "#index" \n\t"\ + "cmp "dstw", "#index" \n\t"\ " jb 1b \n\t" #define WRITEYUY2(dst, dstw, index) REAL_WRITEYUY2(dst, dstw, index) @@ -731,7 +731,7 @@ static void RENAME(yuv2yuyv422_X_ar)(SwsContext *c, const int16_t *lumFilter, "psraw $3, %%mm4 \n\t" "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" - WRITEYUY2(%4, %5, %%REGa) + WRITEYUY2(%4, "%5", %%REGa) YSCALEYUV2PACKEDX_END } @@ -752,7 +752,7 @@ static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter, "psraw $3, %%mm4 \n\t" "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" - WRITEYUY2(%4, %5, %%REGa) + WRITEYUY2(%4, "%5", %%REGa) YSCALEYUV2PACKEDX_END } @@ -853,7 +853,7 @@ static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2], "psraw $3, %%mm1 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/ "psraw $3, %%mm7 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/ "packuswb %%mm7, %%mm1 \n\t" - WRITEBGR32(%4, 8280(%5), %%r8, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) + WRITEBGR32(%4, DSTW_OFFSET"(%5)", %%r8, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "r" (dest), "a" (&c->redDither), "r" (abuf0), "r" (abuf1) @@ -877,7 +877,7 @@ static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2], "packuswb %%mm7, %%mm1 \n\t" "pop %1 \n\t" "pop %0 \n\t" - WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) + WRITEBGR32(%%REGb, DSTW_OFFSET"(%5)", %%REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -891,7 +891,7 @@ static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2], "push %%"REG_BP" \n\t" YSCALEYUV2RGB(%%REGBP, %5) "pcmpeqd %%mm7, %%mm7 \n\t" - WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + WRITEBGR32(%%REGb, DSTW_OFFSET"(%5)", %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -908,14 +908,13 @@ static void RENAME(yuv2bgr24_2)(SwsContext *c, const int16_t *buf[2], const int16_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; - //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" - WRITEBGR24(%%REGb, 8280(%5), %%REGBP) + WRITEBGR24(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -931,7 +930,6 @@ static void RENAME(yuv2rgb555_2)(SwsContext *c, const int16_t *buf[2], const int16_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; - //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -944,7 +942,7 @@ static void RENAME(yuv2rgb555_2)(SwsContext *c, const int16_t *buf[2], "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif - WRITERGB15(%%REGb, 8280(%5), %%REGBP) + WRITERGB15(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -960,7 +958,6 @@ static void RENAME(yuv2rgb565_2)(SwsContext *c, const int16_t *buf[2], const int16_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; - //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -973,7 +970,7 @@ static void RENAME(yuv2rgb565_2)(SwsContext *c, const int16_t *buf[2], "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif - WRITERGB16(%%REGb, 8280(%5), %%REGBP) + WRITERGB16(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1029,13 +1026,12 @@ static void RENAME(yuv2yuyv422_2)(SwsContext *c, const int16_t *buf[2], const int16_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1]; - //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :( __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED(%%REGBP, %5) - WRITEYUY2(%%REGb, 8280(%5), %%REGBP) + WRITEYUY2(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1178,7 +1174,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) YSCALEYUV2RGB1_ALPHA(%%REGBP) - WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + WRITEBGR32(%%REGb, DSTW_OFFSET"(%5)", %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1191,7 +1187,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) "pcmpeqd %%mm7, %%mm7 \n\t" - WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + WRITEBGR32(%%REGb, DSTW_OFFSET"(%5)", %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1207,7 +1203,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) YSCALEYUV2RGB1_ALPHA(%%REGBP) - WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + WRITEBGR32(%%REGb, DSTW_OFFSET"(%5)", %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1220,7 +1216,7 @@ static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0, "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) "pcmpeqd %%mm7, %%mm7 \n\t" - WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) + WRITEBGR32(%%REGb, DSTW_OFFSET"(%5)", %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1246,7 +1242,7 @@ static void RENAME(yuv2bgr24_1)(SwsContext *c, const int16_t *buf0, "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" - WRITEBGR24(%%REGb, 8280(%5), %%REGBP) + WRITEBGR24(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1260,7 +1256,7 @@ static void RENAME(yuv2bgr24_1)(SwsContext *c, const int16_t *buf0, "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5) "pxor %%mm7, %%mm7 \n\t" - WRITEBGR24(%%REGb, 8280(%5), %%REGBP) + WRITEBGR24(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1291,7 +1287,7 @@ static void RENAME(yuv2rgb555_1)(SwsContext *c, const int16_t *buf0, "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif - WRITERGB15(%%REGb, 8280(%5), %%REGBP) + WRITERGB15(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1311,7 +1307,7 @@ static void RENAME(yuv2rgb555_1)(SwsContext *c, const int16_t *buf0, "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif - WRITERGB15(%%REGb, 8280(%5), %%REGBP) + WRITERGB15(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1342,7 +1338,7 @@ static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0, "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif - WRITERGB16(%%REGb, 8280(%5), %%REGBP) + WRITERGB16(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1362,7 +1358,7 @@ static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0, "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif - WRITERGB16(%%REGb, 8280(%5), %%REGBP) + WRITERGB16(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1423,7 +1419,7 @@ static void RENAME(yuv2yuyv422_1)(SwsContext *c, const int16_t *buf0, "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED1(%%REGBP, %5) - WRITEYUY2(%%REGb, 8280(%5), %%REGBP) + WRITEYUY2(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), @@ -1436,7 +1432,7 @@ static void RENAME(yuv2yuyv422_1)(SwsContext *c, const int16_t *buf0, "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED1b(%%REGBP, %5) - WRITEYUY2(%%REGb, 8280(%5), %%REGBP) + WRITEYUY2(%%REGb, DSTW_OFFSET"(%5)", %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), diff --git a/tests/Makefile b/tests/Makefile index 68620006cb..96d53c0a9b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -30,7 +30,7 @@ tests/data/vsynth1.yuv: tests/videogen$(HOSTEXESUF) | tests/data tests/data/vsynth2.yuv: tests/rotozoom$(HOSTEXESUF) | tests/data $(M)$< $(SRC_PATH)/tests/lena.pnm $@ -tests/data/ffprobe-test.nut: ffmpeg$(HOSTEXESUF) | tests/data +tests/data/ffprobe-test.nut: ffmpeg$(EXESUF) | tests/data $(M)./$< \ -f lavfi -i "aevalsrc=sin(400*PI*2*t)::d=0.125[out0]; testsrc=d=0.125[out1]; testsrc=s=100x100:d=0.125[out2]" \ -f ffmetadata -i $(SRC_PATH)/tests/test.ffmeta \ diff --git a/tests/fate/lossless-video.mak b/tests/fate/lossless-video.mak index 2ae035b998..cbf7f5292a 100644 --- a/tests/fate/lossless-video.mak +++ b/tests/fate/lossless-video.mak @@ -40,11 +40,13 @@ fate-mszh: CMD = framecrc -i $(SAMPLES)/lcl/mszh-1frame.avi FATE_LOSSLESS_VIDEO += fate-vble fate-vble: CMD = framecrc -i $(SAMPLES)/vble/flowers-partial-2MB.avi -FATE_LOSSLESS_VIDEO += fate-zlib +FATE_LOSSLESS_VIDEO-$(CONFIG_ZLIB) += fate-zlib fate-zlib: CMD = framecrc -i $(SAMPLES)/lcl/zlib-1frame.avi -FATE_LOSSLESS_VIDEO += fate-zerocodec +FATE_LOSSLESS_VIDEO-$(CONFIG_ZLIB) += fate-zerocodec fate-zerocodec: CMD = framecrc -i $(SAMPLES)/zerocodec/sample-zeco.avi +FATE_LOSSLESS_VIDEO += $(FATE_LOSSLESS_VIDEO-yes) + FATE_SAMPLES_FFMPEG += $(FATE_LOSSLESS_VIDEO) fate-lossless-video: $(FATE_LOSSLESS_VIDEO) diff --git a/tests/fate/qt.mak b/tests/fate/qt.mak index c626245157..3068ac63ec 100644 --- a/tests/fate/qt.mak +++ b/tests/fate/qt.mak @@ -46,8 +46,10 @@ fate-rpza: CMD = framecrc -i $(SAMPLES)/rpza/rpza2.mov -t 2 -pix_fmt rgb24 FATE_QT += fate-svq1 fate-svq1: CMD = framecrc -i $(SAMPLES)/svq1/marymary-shackles.mov -an -t 10 -FATE_QT += fate-svq3 +FATE_QT-$(CONFIG_ZLIB) += fate-svq3 fate-svq3: CMD = framecrc -i $(SAMPLES)/svq3/Vertical400kbit.sorenson3.mov -t 6 -an +FATE_QT += $(FATE_QT-yes) + FATE_SAMPLES_FFMPEG += $(FATE_QT) fate-qt: $(FATE_QT) diff --git a/tests/fate/screen.mak b/tests/fate/screen.mak index eb7bafe9c3..14264a6547 100644 --- a/tests/fate/screen.mak +++ b/tests/fate/screen.mak @@ -32,7 +32,7 @@ fate-tscc-15bit: CMD = framecrc -i $(SAMPLES)/tscc/oneminute.avi -t 15 -pix_fmt FATE_TSCC += fate-tscc-32bit fate-tscc-32bit: CMD = framecrc -i $(SAMPLES)/tscc/2004-12-17-uebung9-partial.avi -pix_fmt rgb24 -an -FATE_SCREEN += $(FATE_TSCC) +FATE_SCREEN-$(CONFIG_ZLIB) += $(FATE_TSCC) fate-tscc: $(FATE_TSCC) FATE_VMNC += fate-vmnc-16bit @@ -56,8 +56,10 @@ fate-zmbv-16bit: CMD = framecrc -i $(SAMPLES)/zmbv/zmbv_16bit.avi -pix_fmt rgb24 FATE_ZMBV += fate-zmbv-32bit fate-zmbv-32bit: CMD = framecrc -i $(SAMPLES)/zmbv/zmbv_32bit.avi -pix_fmt rgb24 -t 25 -FATE_SCREEN += $(FATE_ZMBV) +FATE_SCREEN-$(CONFIG_ZLIB) += $(FATE_ZMBV) fate-zmbv: $(FATE_ZMBV) +FATE_SCREEN += $(FATE_SCREEN-yes) + FATE_SAMPLES_FFMPEG += $(FATE_SCREEN) fate-screen: $(FATE_SCREEN) diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak index d4c4cf60be..f4e39b8ce7 100644 --- a/tests/fate/vcodec.mak +++ b/tests/fate/vcodec.mak @@ -59,12 +59,12 @@ fate-vsynth%-ffv1: ENCOPTS = -strict -2 FATE_VCODEC += ffvhuff -FATE_VCODEC += flashsv +FATE_VCODEC-$(CONFIG_ZLIB) += flashsv fate-vsynth%-flashsv: ENCOPTS = -sws_flags neighbor+full_chroma_int fate-vsynth%-flashsv: DECOPTS = -sws_flags area fate-vsynth%-flashsv: FMT = flv -FATE_VCODEC += flashsv2 +FATE_VCODEC-$(CONFIG_ZLIB) += flashsv2 fate-vsynth%-flashsv2: ENCOPTS = -sws_flags neighbor+full_chroma_int -strict experimental -compression_level 0 fate-vsynth%-flashsv2: DECOPTS = -sws_flags area fate-vsynth%-flashsv2: FMT = flv @@ -193,7 +193,7 @@ fate-vsynth%-msmpeg4: ENCOPTS = -qscale 10 FATE_VCODEC += msmpeg4v2 fate-vsynth%-msmpeg4v2: ENCOPTS = -qscale 10 -FATE_VCODEC += mpng +FATE_VCODEC-$(CONFIG_ZLIB) += mpng fate-vsynth%-mpng: CODEC = png FATE_VCODEC += msvideo1 @@ -277,8 +277,9 @@ FATE_VCODEC += yuv4 FATE_VCODEC += y41p -FATE_VCODEC += zlib +FATE_VCODEC-$(CONFIG_ZLIB) += zlib +FATE_VCODEC += $(FATE_VCODEC-yes) FATE_VSYNTH1 = $(FATE_VCODEC:%=fate-vsynth1-%) FATE_VSYNTH2 = $(FATE_VCODEC:%=fate-vsynth2-%) diff --git a/tests/fate/video.mak b/tests/fate/video.mak index e5dd6201c3..65b98a47d8 100644 --- a/tests/fate/video.mak +++ b/tests/fate/video.mak @@ -49,7 +49,7 @@ fate-cdgraphics: CMD = framecrc -i $(SAMPLES)/cdgraphics/BrotherJohn.cdg -pix_fm FATE_VIDEO += fate-cljr fate-cljr: CMD = framecrc -i $(SAMPLES)/cljr/testcljr-partial.avi -FATE_VIDEO += fate-corepng +FATE_VIDEO-$(CONFIG_ZLIB) += fate-corepng fate-corepng: CMD = framecrc -i $(SAMPLES)/png1/corepng-partial.avi FATE_VIDEO += fate-creatureshock-avs @@ -97,7 +97,7 @@ fate-dxa-feeble: CMD = framecrc -i $(SAMPLES)/dxa/meetsquid.dxa -t 2 -pix_fmt rg FATE_DXA += fate-dxa-scummvm fate-dxa-scummvm: CMD = framecrc -i $(SAMPLES)/dxa/scummvm.dxa -pix_fmt rgb24 -FATE_VIDEO += $(FATE_DXA) +FATE_VIDEO-$(CONFIG_ZLIB) += $(FATE_DXA) fate-dxa: $(FATE_DXA) FATE_SAMPLES_PCM += fate-film-cvid diff --git a/tests/ref/fate/ffprobe_compact b/tests/ref/fate/ffprobe_compact index 71239fe859..0a4733949e 100644 --- a/tests/ref/fate/ffprobe_compact +++ b/tests/ref/fate/ffprobe_compact @@ -26,7 +26,7 @@ packet|codec_type=video|stream_index=1|pts=3|pts_time=0.120000|dts=3|dts_time=0. frame|media_type=video|key_frame=1|pkt_pts=3|pkt_pts_time=0.120000|pkt_dts=3|pkt_dts_time=0.120000|pkt_duration=1|pkt_duration_time=0.040000|pkt_pos=794128|width=320|height=240|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|reference=0 packet|codec_type=video|stream_index=2|pts=3|pts_time=0.120000|dts=3|dts_time=0.120000|duration=1|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=30000|pos=1024550|flags=K frame|media_type=video|key_frame=1|pkt_pts=3|pkt_pts_time=0.120000|pkt_dts=3|pkt_dts_time=0.120000|pkt_duration=1|pkt_duration_time=0.040000|pkt_pos=1024550|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|reference=0 -stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_time_base=1/44100|codec_tag_string=[1][0][0][0]|codec_tag=0x0001|default=0|forced=0|sample_fmt=s16|sample_rate=44100|channels=1|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=527313|duration=11.957211|bit_rate=705600|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6 -stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|default=0|forced=0|width=320|height=240|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|timecode=N/A|attached_pic=0|id=N/A|r_frame_rate=25/1|avg_frame_rate=0/0|time_base=1/25|start_pts=0|start_time=0.000000|duration_ts=299|duration=11.960000|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4 -stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|default=0|forced=0|width=100|height=100|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|timecode=N/A|attached_pic=0|id=N/A|r_frame_rate=25/1|avg_frame_rate=0/0|time_base=1/25|start_pts=0|start_time=0.000000|duration_ts=299|duration=11.960000|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4 +stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_time_base=1/44100|codec_tag_string=[1][0][0][0]|codec_tag=0x0001|sample_fmt=s16|sample_rate=44100|channels=1|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=527313|duration=11.957211|bit_rate=705600|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6 +stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|timecode=N/A|id=N/A|r_frame_rate=25/1|avg_frame_rate=0/0|time_base=1/25|start_pts=0|start_time=0.000000|duration_ts=299|duration=11.960000|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4 +stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|timecode=N/A|id=N/A|r_frame_rate=25/1|avg_frame_rate=0/0|time_base=1/25|start_pts=0|start_time=0.000000|duration_ts=299|duration=11.960000|bit_rate=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4 format|filename=tests/data/ffprobe-test.nut|nb_streams=3|format_name=nut|start_time=0.000000|duration=11.960000|size=1054625|bit_rate=705434|tag:title=ffprobe test file|tag:comment='A comment with CSV, XML & JSON special chars': |tag:comment2=I ♥ Üñîçød€ diff --git a/tests/ref/fate/ffprobe_csv b/tests/ref/fate/ffprobe_csv index 86e4a1a285..f56acaca69 100644 --- a/tests/ref/fate/ffprobe_csv +++ b/tests/ref/fate/ffprobe_csv @@ -26,7 +26,7 @@ packet,video,1,3,0.120000,3,0.120000,1,0.040000,N/A,N/A,230400,794128,K frame,video,1,3,0.120000,3,0.120000,1,0.040000,794128,320,240,rgb24,1:1,I,0,0,0,0,0,0 packet,video,2,3,0.120000,3,0.120000,1,0.040000,N/A,N/A,30000,1024550,K frame,video,1,3,0.120000,3,0.120000,1,0.040000,1024550,100,100,rgb24,1:1,I,0,0,0,0,0,0 -stream,0,pcm_s16le,unknown,audio,1/44100,[1][0][0][0],0x0001,0,0,s16,44100,1,16,N/A,0/0,0/0,1/44100,0,0.000000,527313,11.957211,705600,N/A,6,6 -stream,1,rawvideo,unknown,video,1/25,RGB[24],0x18424752,0,0,320,240,0,1:1,4:3,rgb24,-99,N/A,0,N/A,25/1,0/0,1/25,0,0.000000,299,11.960000,N/A,N/A,4,4 -stream,2,rawvideo,unknown,video,1/25,RGB[24],0x18424752,0,0,100,100,0,1:1,1:1,rgb24,-99,N/A,0,N/A,25/1,0/0,1/25,0,0.000000,299,11.960000,N/A,N/A,4,4 +stream,0,pcm_s16le,unknown,audio,1/44100,[1][0][0][0],0x0001,s16,44100,1,16,N/A,0/0,0/0,1/44100,0,0.000000,527313,11.957211,705600,N/A,6,6 +stream,1,rawvideo,unknown,video,1/25,RGB[24],0x18424752,320,240,0,1:1,4:3,rgb24,-99,N/A,N/A,25/1,0/0,1/25,0,0.000000,299,11.960000,N/A,N/A,4,4 +stream,2,rawvideo,unknown,video,1/25,RGB[24],0x18424752,100,100,0,1:1,1:1,rgb24,-99,N/A,N/A,25/1,0/0,1/25,0,0.000000,299,11.960000,N/A,N/A,4,4 format,tests/data/ffprobe-test.nut,3,nut,0.000000,11.960000,1054625,705434,ffprobe test file,"'A comment with CSV, XML & JSON special chars': ",I ♥ Üñîçød€ diff --git a/tests/ref/fate/ffprobe_default b/tests/ref/fate/ffprobe_default index a9b555bf36..8b7a1c38ad 100644 --- a/tests/ref/fate/ffprobe_default +++ b/tests/ref/fate/ffprobe_default @@ -482,8 +482,6 @@ codec_type=audio codec_time_base=1/44100 codec_tag_string=[1][0][0][0] codec_tag=0x0001 -default=0 -forced=0 sample_fmt=s16 sample_rate=44100 channels=1 @@ -509,8 +507,6 @@ codec_type=video codec_time_base=1/25 codec_tag_string=RGB[24] codec_tag=0x18424752 -default=0 -forced=0 width=320 height=240 has_b_frames=0 @@ -519,7 +515,6 @@ display_aspect_ratio=4:3 pix_fmt=rgb24 level=-99 timecode=N/A -attached_pic=0 id=N/A r_frame_rate=25/1 avg_frame_rate=0/0 @@ -541,8 +536,6 @@ codec_type=video codec_time_base=1/25 codec_tag_string=RGB[24] codec_tag=0x18424752 -default=0 -forced=0 width=100 height=100 has_b_frames=0 @@ -551,7 +544,6 @@ display_aspect_ratio=1:1 pix_fmt=rgb24 level=-99 timecode=N/A -attached_pic=0 id=N/A r_frame_rate=25/1 avg_frame_rate=0/0 diff --git a/tests/ref/fate/ffprobe_flat b/tests/ref/fate/ffprobe_flat index e9e2f87423..f9692b2fcc 100644 --- a/tests/ref/fate/ffprobe_flat +++ b/tests/ref/fate/ffprobe_flat @@ -425,8 +425,6 @@ streams.stream.0.codec_type="audio" streams.stream.0.codec_time_base="1/44100" streams.stream.0.codec_tag_string="[1][0][0][0]" streams.stream.0.codec_tag="0x0001" -streams.stream.0.default=0 -streams.stream.0.forced=0 streams.stream.0.sample_fmt="s16" streams.stream.0.sample_rate="44100" streams.stream.0.channels=1 @@ -450,8 +448,6 @@ streams.stream.1.codec_type="video" streams.stream.1.codec_time_base="1/25" streams.stream.1.codec_tag_string="RGB[24]" streams.stream.1.codec_tag="0x18424752" -streams.stream.1.default=0 -streams.stream.1.forced=0 streams.stream.1.width=320 streams.stream.1.height=240 streams.stream.1.has_b_frames=0 @@ -460,7 +456,6 @@ streams.stream.1.display_aspect_ratio="4:3" streams.stream.1.pix_fmt="rgb24" streams.stream.1.level=-99 streams.stream.1.timecode="N/A" -streams.stream.1.attached_pic=0 streams.stream.1.id="N/A" streams.stream.1.r_frame_rate="25/1" streams.stream.1.avg_frame_rate="0/0" @@ -480,8 +475,6 @@ streams.stream.2.codec_type="video" streams.stream.2.codec_time_base="1/25" streams.stream.2.codec_tag_string="RGB[24]" streams.stream.2.codec_tag="0x18424752" -streams.stream.2.default=0 -streams.stream.2.forced=0 streams.stream.2.width=100 streams.stream.2.height=100 streams.stream.2.has_b_frames=0 @@ -490,7 +483,6 @@ streams.stream.2.display_aspect_ratio="1:1" streams.stream.2.pix_fmt="rgb24" streams.stream.2.level=-99 streams.stream.2.timecode="N/A" -streams.stream.2.attached_pic=0 streams.stream.2.id="N/A" streams.stream.2.r_frame_rate="25/1" streams.stream.2.avg_frame_rate="0/0" diff --git a/tests/ref/fate/ffprobe_ini b/tests/ref/fate/ffprobe_ini index 1c3865902f..aef5d9a966 100644 --- a/tests/ref/fate/ffprobe_ini +++ b/tests/ref/fate/ffprobe_ini @@ -484,8 +484,6 @@ codec_type=audio codec_time_base=1/44100 codec_tag_string=[1][0][0][0] codec_tag=0x0001 -default=0 -forced=0 sample_fmt=s16 sample_rate=44100 channels=1 @@ -511,8 +509,6 @@ codec_type=video codec_time_base=1/25 codec_tag_string=RGB[24] codec_tag=0x18424752 -default=0 -forced=0 width=320 height=240 has_b_frames=0 @@ -521,7 +517,6 @@ display_aspect_ratio=4\:3 pix_fmt=rgb24 level=-99 timecode=N/A -attached_pic=0 id=N/A r_frame_rate=25/1 avg_frame_rate=0/0 @@ -543,8 +538,6 @@ codec_type=video codec_time_base=1/25 codec_tag_string=RGB[24] codec_tag=0x18424752 -default=0 -forced=0 width=100 height=100 has_b_frames=0 @@ -553,7 +546,6 @@ display_aspect_ratio=1\:1 pix_fmt=rgb24 level=-99 timecode=N/A -attached_pic=0 id=N/A r_frame_rate=25/1 avg_frame_rate=0/0 diff --git a/tests/ref/fate/ffprobe_json b/tests/ref/fate/ffprobe_json index 27b9cd2cfd..fb1a6f6807 100644 --- a/tests/ref/fate/ffprobe_json +++ b/tests/ref/fate/ffprobe_json @@ -479,8 +479,6 @@ "codec_time_base": "1/44100", "codec_tag_string": "[1][0][0][0]", "codec_tag": "0x0001", - "default": 0, - "forced": 0, "sample_fmt": "s16", "sample_rate": "44100", "channels": 1, @@ -503,8 +501,6 @@ "codec_time_base": "1/25", "codec_tag_string": "RGB[24]", "codec_tag": "0x18424752", - "default": 0, - "forced": 0, "width": 320, "height": 240, "has_b_frames": 0, @@ -512,7 +508,6 @@ "display_aspect_ratio": "4:3", "pix_fmt": "rgb24", "level": -99, - "attached_pic": 0, "r_frame_rate": "25/1", "avg_frame_rate": "0/0", "time_base": "1/25", @@ -530,8 +525,6 @@ "codec_time_base": "1/25", "codec_tag_string": "RGB[24]", "codec_tag": "0x18424752", - "default": 0, - "forced": 0, "width": 100, "height": 100, "has_b_frames": 0, @@ -539,7 +532,6 @@ "display_aspect_ratio": "1:1", "pix_fmt": "rgb24", "level": -99, - "attached_pic": 0, "r_frame_rate": "25/1", "avg_frame_rate": "0/0", "time_base": "1/25", diff --git a/tests/ref/fate/ffprobe_xml b/tests/ref/fate/ffprobe_xml index 623766409e..e73a15c7b5 100644 --- a/tests/ref/fate/ffprobe_xml +++ b/tests/ref/fate/ffprobe_xml @@ -32,9 +32,9 @@ - - - + + + diff --git a/tests/ref/lavf-fate/mp3 b/tests/ref/lavf-fate/mp3 index 91e2b48c03..361314b2ca 100644 --- a/tests/ref/lavf-fate/mp3 +++ b/tests/ref/lavf-fate/mp3 @@ -1,3 +1,3 @@ -40a4e41ae74ec8dacdf02402831a6a58 *./tests/data/lavf-fate/lavf.mp3 -97230 ./tests/data/lavf-fate/lavf.mp3 +7fcf80c2059b5c058a6cdd2e2f798b6c *./tests/data/lavf-fate/lavf.mp3 +96366 ./tests/data/lavf-fate/lavf.mp3 ./tests/data/lavf-fate/lavf.mp3 CRC=0x6c9850fe diff --git a/tests/ref/lavf/asf b/tests/ref/lavf/asf index 5777d8b1a7..cfa53dcc73 100644 --- a/tests/ref/lavf/asf +++ b/tests/ref/lavf/asf @@ -1,3 +1,3 @@ -6dfad1f3d0f2638ea46f08edaf482f26 *./tests/data/lavf/lavf.asf +3937dfece4b48c0cdd8f44bcab3cdd2d *./tests/data/lavf/lavf.asf 333581 ./tests/data/lavf/lavf.asf ./tests/data/lavf/lavf.asf CRC=0x51485213 diff --git a/tests/ref/lavf/dpx b/tests/ref/lavf/dpx index 1196934836..70371d8115 100644 --- a/tests/ref/lavf/dpx +++ b/tests/ref/lavf/dpx @@ -1,9 +1,9 @@ -808ea110635774252439722a48329d61 *./tests/data/images/dpx/02.dpx +d2f0b4e854fda2d3b3bee84cef80593c *./tests/data/images/dpx/02.dpx ./tests/data/images/dpx/%02d.dpx CRC=0x6da01946 305792 ./tests/data/images/dpx/02.dpx -5e1a777fa3f4094c9c4dd989cf9e8e8b *./tests/data/images/dpx/02.dpx +075963c3c08978b6a20555ba09161434 *./tests/data/images/dpx/02.dpx ./tests/data/images/dpx/%02d.dpx CRC=0xe5b9c023 609920 ./tests/data/images/dpx/02.dpx -13dc41b1e1e36399a5e1f8b7e3344a81 *./tests/data/images/dpx/02.dpx +b9f22728f8ff393bf30cf6cbd624fa95 *./tests/data/images/dpx/02.dpx ./tests/data/images/dpx/%02d.dpx CRC=0xf0a1c097 407168 ./tests/data/images/dpx/02.dpx diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv index 8820300100..33a5c18677 100644 --- a/tests/ref/lavf/mkv +++ b/tests/ref/lavf/mkv @@ -1,3 +1,3 @@ -796a3bbf2410e55e186367037bda6bb5 *./tests/data/lavf/lavf.mkv -320297 ./tests/data/lavf/lavf.mkv +32892841431db4b1149666cf94a8a714 *./tests/data/lavf/lavf.mkv +320265 ./tests/data/lavf/lavf.mkv ./tests/data/lavf/lavf.mkv CRC=0x7065846b diff --git a/tests/ref/seek/lavf_asf b/tests/ref/seek/lavf_asf index 1427997890..9a14895513 100644 --- a/tests/ref/seek/lavf_asf +++ b/tests/ref/seek/lavf_asf @@ -1,53 +1,53 @@ -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 1 flags:1 dts: 0.459000 pts: 0.459000 pos: 147889 size: 209 +ret: 0 st: 1 flags:1 dts: 0.470000 pts: 0.470000 pos: 147889 size: 209 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 1 flags:1 dts: 0.459000 pts: 0.459000 pos: 147889 size: 209 +ret: 0 st: 1 flags:1 dts: 0.470000 pts: 0.470000 pos: 147889 size: 209 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st: 1 flags:0 ts: 2.577000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 330289 size: 209 +ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 330289 size: 209 ret: 0 st: 1 flags:1 ts: 1.471000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 330289 size: 209 +ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 330289 size: 209 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 1 flags:1 dts: 0.459000 pts: 0.459000 pos: 147889 size: 209 +ret: 0 st: 1 flags:1 dts: 0.470000 pts: 0.470000 pos: 147889 size: 209 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st: 0 flags:0 ts: 2.153000 -ret: 0 st: 1 flags:1 dts: 0.930000 pts: 0.930000 pos: 301489 size: 209 +ret: 0 st: 1 flags:1 dts: 0.941000 pts: 0.941000 pos: 301489 size: 209 ret: 0 st: 0 flags:1 ts: 1.048000 -ret: 0 st: 1 flags:1 dts: 0.930000 pts: 0.930000 pos: 301489 size: 209 +ret: 0 st: 1 flags:1 dts: 0.941000 pts: 0.941000 pos: 301489 size: 209 ret: 0 st: 1 flags:0 ts:-0.058000 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st: 1 flags:1 ts: 2.836000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 330289 size: 209 +ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 330289 size: 209 ret: 0 st:-1 flags:0 ts: 1.730004 -ret: 0 st: 1 flags:1 dts: 0.930000 pts: 0.930000 pos: 301489 size: 209 +ret: 0 st: 1 flags:1 dts: 0.941000 pts: 0.941000 pos: 301489 size: 209 ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st: 0 flags:0 ts:-0.482000 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st: 0 flags:1 ts: 2.413000 -ret: 0 st: 1 flags:1 dts: 0.930000 pts: 0.930000 pos: 301489 size: 209 +ret: 0 st: 1 flags:1 dts: 0.941000 pts: 0.941000 pos: 301489 size: 209 ret: 0 st: 1 flags:0 ts: 1.307000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 330289 size: 209 +ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 330289 size: 209 ret: 0 st: 1 flags:1 ts: 0.201000 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st:-1 flags:0 ts:-0.904994 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 1 flags:1 dts: 0.930000 pts: 0.930000 pos: 301489 size: 209 +ret: 0 st: 1 flags:1 dts: 0.941000 pts: 0.941000 pos: 301489 size: 209 ret: 0 st: 0 flags:0 ts: 0.883000 -ret: 0 st: 1 flags:1 dts: 0.459000 pts: 0.459000 pos: 147889 size: 209 +ret: 0 st: 1 flags:1 dts: 0.470000 pts: 0.470000 pos: 147889 size: 209 ret: 0 st: 0 flags:1 ts:-0.222000 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 ret: 0 st: 1 flags:0 ts: 2.672000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 330289 size: 209 +ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 330289 size: 209 ret: 0 st: 1 flags:1 ts: 1.566000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 330289 size: 209 +ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 330289 size: 209 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 1 flags:1 dts: 0.459000 pts: 0.459000 pos: 147889 size: 209 +ret: 0 st: 1 flags:1 dts: 0.470000 pts: 0.470000 pos: 147889 size: 209 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 689 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 689 size: 208 diff --git a/tests/ref/seek/lavf_mkv b/tests/ref/seek/lavf_mkv index ece15a1d75..02427cb1b9 100644 --- a/tests/ref/seek/lavf_mkv +++ b/tests/ref/seek/lavf_mkv @@ -1,48 +1,48 @@ -ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 523 size: 208 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 523 size: 208 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292185 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292153 size: 27834 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292185 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292153 size: 27834 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 523 size: 208 ret:-1 st: 1 flags:0 ts: 2.577000 ret: 0 st: 1 flags:1 ts: 1.471000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320026 size: 209 +ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 319994 size: 209 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146738 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146706 size: 27925 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 523 size: 208 ret:-1 st: 0 flags:0 ts: 2.153000 ret: 0 st: 0 flags:1 ts: 1.048000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292185 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292153 size: 27834 ret: 0 st: 1 flags:0 ts:-0.058000 -ret: 0 st: 1 flags:1 dts: 0.015000 pts: 0.015000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.015000 pts: 0.015000 pos: 523 size: 208 ret: 0 st: 1 flags:1 ts: 2.836000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320026 size: 209 +ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 319994 size: 209 ret:-1 st:-1 flags:0 ts: 1.730004 ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146738 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146706 size: 27925 ret: 0 st: 0 flags:0 ts:-0.482000 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 523 size: 208 ret: 0 st: 0 flags:1 ts: 2.413000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292185 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292153 size: 27834 ret:-1 st: 1 flags:0 ts: 1.307000 ret: 0 st: 1 flags:1 ts: 0.201000 -ret: 0 st: 1 flags:1 dts: 0.015000 pts: 0.015000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.015000 pts: 0.015000 pos: 523 size: 208 ret: 0 st:-1 flags:0 ts:-0.904994 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 523 size: 208 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292185 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292153 size: 27834 ret: 0 st: 0 flags:0 ts: 0.883000 -ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292185 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292153 size: 27834 ret: 0 st: 0 flags:1 ts:-0.222000 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 523 size: 208 ret:-1 st: 1 flags:0 ts: 2.672000 ret: 0 st: 1 flags:1 ts: 1.566000 -ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320026 size: 209 +ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 319994 size: 209 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146738 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146706 size: 27925 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 555 size: 208 +ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 523 size: 208