From 139f3ac42dcf24eb8c59af4aaab4e9afdccbc996 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:18:16 +0100 Subject: [PATCH 001/172] Bump major versions of all libraries. They've accumulated enough new APIs and corresponding deprecated cruft. This breaks API and ABI. --- libavcodec/version.h | 4 ++-- libavdevice/avdevice.h | 4 ++-- libavfilter/avfilter.h | 4 ++-- libavformat/version.h | 4 ++-- libavutil/avutil.h | 6 +++--- libpostproc/postprocess.h | 4 ++-- libswscale/swscale.h | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 1a470a1e91..7e5347404d 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -20,8 +20,8 @@ #ifndef AVCODEC_VERSION_H #define AVCODEC_VERSION_H -#define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 120 +#define LIBAVCODEC_VERSION_MAJOR 53 +#define LIBAVCODEC_VERSION_MINOR 0 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index 497683a11b..d1e321bf3a 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -21,8 +21,8 @@ #include "libavutil/avutil.h" -#define LIBAVDEVICE_VERSION_MAJOR 52 -#define LIBAVDEVICE_VERSION_MINOR 4 +#define LIBAVDEVICE_VERSION_MAJOR 53 +#define LIBAVDEVICE_VERSION_MINOR 0 #define LIBAVDEVICE_VERSION_MICRO 0 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 74435813fa..7505c2eecd 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -25,8 +25,8 @@ #include "libavutil/avutil.h" #include "libavutil/samplefmt.h" -#define LIBAVFILTER_VERSION_MAJOR 1 -#define LIBAVFILTER_VERSION_MINOR 77 +#define LIBAVFILTER_VERSION_MAJOR 2 +#define LIBAVFILTER_VERSION_MINOR 0 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavformat/version.h b/libavformat/version.h index f777063178..b21938aaef 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -23,8 +23,8 @@ #include "libavutil/avutil.h" -#define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 108 +#define LIBAVFORMAT_VERSION_MAJOR 53 +#define LIBAVFORMAT_VERSION_MINOR 0 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 4c86be1b86..6f2517c092 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -39,9 +39,9 @@ #define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) -#define LIBAVUTIL_VERSION_MAJOR 50 -#define LIBAVUTIL_VERSION_MINOR 40 -#define LIBAVUTIL_VERSION_MICRO 1 +#define LIBAVUTIL_VERSION_MAJOR 51 +#define LIBAVUTIL_VERSION_MINOR 0 +#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h index 96a1dbea19..9e74589455 100644 --- a/libpostproc/postprocess.h +++ b/libpostproc/postprocess.h @@ -29,8 +29,8 @@ #include "libavutil/avutil.h" -#define LIBPOSTPROC_VERSION_MAJOR 51 -#define LIBPOSTPROC_VERSION_MINOR 2 +#define LIBPOSTPROC_VERSION_MAJOR 52 +#define LIBPOSTPROC_VERSION_MINOR 0 #define LIBPOSTPROC_VERSION_MICRO 0 #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \ diff --git a/libswscale/swscale.h b/libswscale/swscale.h index aae1a6cc7e..5b0802c972 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -29,8 +29,8 @@ #include "libavutil/avutil.h" -#define LIBSWSCALE_VERSION_MAJOR 0 -#define LIBSWSCALE_VERSION_MINOR 12 +#define LIBSWSCALE_VERSION_MAJOR 1 +#define LIBSWSCALE_VERSION_MINOR 0 #define LIBSWSCALE_VERSION_MICRO 0 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ From facc48f157a282e9d99a9bf65f5985bace4606b9 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 18 Apr 2011 22:12:50 +0200 Subject: [PATCH 002/172] libvo-aacenc,libvo-amrwbenc}: fix api usage Use the correct error codes and format identifier. --- libavcodec/libvo-aacenc.c | 8 ++++---- libavcodec/libvo-amrwbenc.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index f2a19a1814..5a75bcbbb4 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -59,7 +59,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) if (s->codec_api.SetParam(s->handle, VO_PID_AAC_ENCPARAM, ¶ms) != VO_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Unable to set encoding parameters\n"); - return AVERROR_UNKNOWN; + return AVERROR(EINVAL); } for (index = 0; index < 16; index++) @@ -68,7 +68,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) if (index == 16) { av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate); - return AVERROR_NOTSUPP; + return AVERROR(ENOSYS); } if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { avctx->extradata_size = 2; @@ -110,14 +110,14 @@ static int aac_encode_frame(AVCodecContext *avctx, if (s->codec_api.GetOutputData(s->handle, &output, &output_info) != VO_ERR_NONE) { av_log(avctx, AV_LOG_ERROR, "Unable to encode frame\n"); - return AVERROR_UNKNOWN; + return AVERROR(EINVAL); } return output.Length; } AVCodec ff_libvo_aacenc_encoder = { "libvo_aacenc", - CODEC_TYPE_AUDIO, + AVMEDIA_TYPE_AUDIO, CODEC_ID_AAC, sizeof(AACContext), aac_encode_init, diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index d8a6099561..b3615ede42 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -119,7 +119,7 @@ static int amr_wb_encode_frame(AVCodecContext *avctx, AVCodec ff_libvo_amrwbenc_encoder = { "libvo_amrwbenc", - CODEC_TYPE_AUDIO, + AVMEDIA_TYPE_AUDIO, CODEC_ID_AMR_WB, sizeof(AMRWBContext), amr_wb_encode_init, From d11818eff42681eec9b8106e317a95766506821a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 18 Apr 2011 23:12:40 +0200 Subject: [PATCH 003/172] Remove now obsolete references to _g-suffixed binaries. Automatic stripping of binaries was removed in commit e0be794 and the _g binaries disappeared along with it. --- doc/faq.texi | 6 ------ tests/copycooker.sh | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/faq.texi b/doc/faq.texi index 3daf44fe7a..a29af1e1ad 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -415,12 +415,6 @@ be rewritten in a formal object language. Further, many of the developers favor straight C; it works for them. For more arguments on this matter, read "Programming Religion" at (@url{http://www.tux.org/lkml/#s15}). -@section Why are the ffmpeg programs devoid of debugging symbols? - -The build process creates ffmpeg_g, ffplay_g, etc. which contain full debug -information. Those binaries are stripped to create ffmpeg, ffplay, etc. If -you need the debug information, use the *_g versions. - @section I do not like the LGPL, can I contribute code under the GPL instead? Yes, as long as the code is optional and can easily and cleanly be placed diff --git a/tests/copycooker.sh b/tests/copycooker.sh index 4b5811dcf6..3118e3f842 100755 --- a/tests/copycooker.sh +++ b/tests/copycooker.sh @@ -13,8 +13,8 @@ rm -f $logfile for i in $list ; do echo ---------------- >> $logfile echo $i >> $logfile - ./ffmpeg_g -flags +bitexact -i $i -acodec copy -vcodec copy -y first.nut - ./ffmpeg_g -flags +bitexact -i first.nut -acodec copy -vcodec copy -y second.nut + ./ffmpeg -flags +bitexact -i $i -acodec copy -vcodec copy -y first.nut + ./ffmpeg -flags +bitexact -i first.nut -acodec copy -vcodec copy -y second.nut cmp first.nut second.nut >> $logfile md5sum first.nut >> $logfile done From 280a789fe218351a1f137366a1eabde87313049a Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 19 Apr 2011 03:09:11 +0200 Subject: [PATCH 004/172] Make MLP/TrueHD channel layout functions visible to the decoder. --- libavcodec/mlp_parser.c | 10 +++++----- libavcodec/mlp_parser.h | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index 5f0b49a0af..834f9d406c 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -43,7 +43,7 @@ static const uint8_t mlp_channels[32] = { 5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static const uint64_t mlp_layout[32] = { +const uint64_t ff_mlp_layout[32] = { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_2_1, @@ -107,7 +107,7 @@ static int truehd_channels(int chanmap) return channels; } -static int64_t truehd_layout(int chanmap) +int64_t ff_truehd_layout(int chanmap) { int layout = 0, i; @@ -316,15 +316,15 @@ static int mlp_parse(AVCodecParserContext *s, if (mh.stream_type == 0xbb) { /* MLP stream */ avctx->channels = mlp_channels[mh.channels_mlp]; - avctx->channel_layout = mlp_layout[mh.channels_mlp]; + avctx->channel_layout = ff_mlp_layout[mh.channels_mlp]; } else { /* mh.stream_type == 0xba */ /* TrueHD stream */ if (mh.channels_thd_stream2) { avctx->channels = truehd_channels(mh.channels_thd_stream2); - avctx->channel_layout = truehd_layout(mh.channels_thd_stream2); + avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream2); } else { avctx->channels = truehd_channels(mh.channels_thd_stream1); - avctx->channel_layout = truehd_layout(mh.channels_thd_stream1); + avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream1); } if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) { avctx->channel_layout = 0; diff --git a/libavcodec/mlp_parser.h b/libavcodec/mlp_parser.h index d7ce2b8311..6e43bc38dc 100644 --- a/libavcodec/mlp_parser.h +++ b/libavcodec/mlp_parser.h @@ -54,6 +54,9 @@ typedef struct MLPHeaderInfo int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb); +int64_t ff_truehd_layout(int chanmap); + +extern const uint64_t ff_mlp_layout[32]; #endif /* AVCODEC_MLP_PARSER_H */ From d3f126df4bf97d464ca34b7071283f692af9f541 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 19 Apr 2011 03:18:08 +0200 Subject: [PATCH 005/172] Also set the MLP/TrueHD channel layout in the decoder. Applications might not use the parser, --- libavcodec/mlpdec.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 044df5bc6a..7b3bd710bb 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -329,6 +329,23 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) for (substr = 0; substr < MAX_SUBSTREAMS; substr++) m->substream[substr].restart_seen = 0; + if (mh.stream_type == 0xbb) { + /* MLP stream */ + m->avctx->channel_layout = ff_mlp_layout[mh.channels_mlp]; + } else { /* mh.stream_type == 0xba */ + /* TrueHD stream */ + if (mh.channels_thd_stream2) { + m->avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream2); + } else { + m->avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream1); + } + if (m->avctx->channels && + av_get_channel_layout_nb_channels(m->avctx->channel_layout) != m->avctx->channels) { + m->avctx->channel_layout = 0; + av_log_ask_for_sample(m->avctx, "Unknown channel layout."); + } + } + m->needs_reordering = mh.channels_mlp >= 18 && mh.channels_mlp <= 20; return 0; From 9b53bb8b3bb89ec1a0f67c34d7c5e6cdcb558b48 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 19 Apr 2011 03:23:46 +0200 Subject: [PATCH 006/172] Only ask once in the code for a TrueHD sample with strange channel layout. --- libavcodec/mlp_parser.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index 834f9d406c..3b87f432ad 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -326,10 +326,6 @@ static int mlp_parse(AVCodecParserContext *s, avctx->channels = truehd_channels(mh.channels_thd_stream1); avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream1); } - if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) { - avctx->channel_layout = 0; - av_log_ask_for_sample(avctx, "Unknown channel layout."); - } } if (!mh.is_vbr) /* Stream is CBR */ From 25347c880f44dbe4bb0f23d6a087c22f4a218c10 Mon Sep 17 00:00:00 2001 From: Gavin Kinsey Date: Tue, 19 Apr 2011 10:16:07 +0200 Subject: [PATCH 007/172] Fix compilation.for iOS ARMv7. --- libavcodec/arm/fft_fixed_neon.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S index 14884d3736..bd6c853ec8 100644 --- a/libavcodec/arm/fft_fixed_neon.S +++ b/libavcodec/arm/fft_fixed_neon.S @@ -122,7 +122,7 @@ endfunc function fft_pass_neon push {r4,lr} - movrel lr, coefs + 24 + movrel lr, coefs+24 vld1.16 {d30}, [lr,:64] lsl r12, r2, #3 vmov d31, d30 From 133208ffb31daeb5eb1d3ef827c2a2d9da78bdad Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 19 Apr 2011 11:50:27 +0200 Subject: [PATCH 008/172] Be more verbose when printing the probe result. --- libavformat/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 1919f61d6a..6421a33456 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -594,9 +594,9 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, *fmt = av_probe_input_format2(&pd, 1, &score); if(*fmt){ if(score <= AVPROBE_SCORE_MAX/4){ //this can only be true in the last iteration - av_log(logctx, AV_LOG_WARNING, "Format detected only with low score of %d, misdetection possible!\n", score); + av_log(logctx, AV_LOG_WARNING, "Format %s detected only with low score of %d, misdetection possible!\n", (*fmt)->name, score); }else - av_log(logctx, AV_LOG_DEBUG, "Probed with size=%d and score=%d\n", probe_size, score); + av_log(logctx, AV_LOG_DEBUG, "Format %s probed with size=%d and score=%d\n", (*fmt)->name, probe_size, score); } } From b0b83973d11a93de142994d3230e7b2b8b42ddb5 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Apr 2011 22:51:04 +0200 Subject: [PATCH 009/172] ffmpeg: remove unused variable padding_src in do_video_out() Signed-off-by: Stefano Sabatini --- ffmpeg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 94d3ede831..9fcd90645f 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1146,7 +1146,7 @@ static void do_video_out(AVFormatContext *s, int *frame_size) { int nb_frames, i, ret; - AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src; + AVFrame *final_picture, *formatted_picture, *resampling_dst; AVCodecContext *enc, *dec; double sync_ipts; @@ -1191,7 +1191,6 @@ static void do_video_out(AVFormatContext *s, formatted_picture = in_picture; final_picture = formatted_picture; - padding_src = formatted_picture; resampling_dst = &ost->pict_tmp; if ( ost->resample_height != ist->st->codec->height @@ -1205,7 +1204,6 @@ static void do_video_out(AVFormatContext *s, #if !CONFIG_AVFILTER if (ost->video_resample) { - padding_src = NULL; final_picture = &ost->pict_tmp; if( ost->resample_height != ist->st->codec->height || ost->resample_width != ist->st->codec->width From 58bc9ac5cbdfac49ba81add3414a9a62e05c11d2 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Apr 2011 23:14:44 +0200 Subject: [PATCH 010/172] ffmpeg: remove unused fields AVOutputStream.original_width/height Signed-off-by: Stefano Sabatini --- ffmpeg.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 9fcd90645f..32597e42e7 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -289,10 +289,6 @@ typedef struct AVOutputStream { float frame_aspect_ratio; - /* full frame size of first frame */ - int original_height; - int original_width; - /* forced key frames */ int64_t *forced_kf_pts; int forced_kf_count; @@ -2310,9 +2306,6 @@ static int transcode(AVFormatContext **output_files, fprintf(stderr, "Cannot get resampling context\n"); ffmpeg_exit(1); } - - ost->original_height = icodec->height; - ost->original_width = icodec->width; #endif codec->bits_per_raw_sample= frame_bits_per_raw_sample; } From dfc6f5ae9038a73f6cedc125b01c95124cb0f102 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Apr 2011 22:58:13 +0200 Subject: [PATCH 011/172] ffmpeg: improve reporting if size/pixel format changes Use av_log() rather than fprintf(stderr, ...), and show information related to the previous size/pixel format configuration. Consistent with the corresponding message issued in case of audio configuration change. Signed-off-by: Stefano Sabatini --- ffmpeg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 32597e42e7..f134f88774 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1192,8 +1192,11 @@ static void do_video_out(AVFormatContext *s, if ( ost->resample_height != ist->st->codec->height || ost->resample_width != ist->st->codec->width || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { - - fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt)); + av_log(NULL, AV_LOG_INFO, + "Input stream #%d.%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", + ist->file_index, ist->index, + ost->resample_width , ost->resample_height , avcodec_get_pix_fmt_name(ost->resample_pix_fmt), + ist->st->codec->width, ist->st->codec->height, avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt)); if(!ost->video_resample) ffmpeg_exit(1); } From 6a46aab49b68a79973dfa86f0966c081fc807961 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Apr 2011 01:38:09 +0200 Subject: [PATCH 012/172] ffmpeg: prefer "dec" over "ist->st->codec" in do_video_out() snippet Simplify, ease readability. Signed-off-by: Stefano Sabatini --- ffmpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index f134f88774..e86e22fe70 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1195,8 +1195,8 @@ static void do_video_out(AVFormatContext *s, av_log(NULL, AV_LOG_INFO, "Input stream #%d.%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", ist->file_index, ist->index, - ost->resample_width , ost->resample_height , avcodec_get_pix_fmt_name(ost->resample_pix_fmt), - ist->st->codec->width, ist->st->codec->height, avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt)); + ost->resample_width, ost->resample_height, avcodec_get_pix_fmt_name(ost->resample_pix_fmt), + dec->width , dec->height , avcodec_get_pix_fmt_name(dec->pix_fmt)); if(!ost->video_resample) ffmpeg_exit(1); } From 0f230c53df9001023b0c9e35b467096336beed85 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Apr 2011 23:11:01 +0200 Subject: [PATCH 013/172] ffmpeg: factorize resampling condition check in do_video_out() Simplify and improve readability. Signed-off-by: Stefano Sabatini --- ffmpeg.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index e86e22fe70..af5fa641ea 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1141,7 +1141,7 @@ static void do_video_out(AVFormatContext *s, AVFrame *in_picture, int *frame_size) { - int nb_frames, i, ret; + int nb_frames, i, ret, resample_changed; AVFrame *final_picture, *formatted_picture, *resampling_dst; AVCodecContext *enc, *dec; double sync_ipts; @@ -1189,9 +1189,11 @@ static void do_video_out(AVFormatContext *s, final_picture = formatted_picture; resampling_dst = &ost->pict_tmp; - if ( ost->resample_height != ist->st->codec->height - || ost->resample_width != ist->st->codec->width - || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { + resample_changed = ost->resample_width != dec->width || + ost->resample_height != dec->height || + ost->resample_pix_fmt != dec->pix_fmt; + + if (resample_changed) { av_log(NULL, AV_LOG_INFO, "Input stream #%d.%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", ist->file_index, ist->index, @@ -1204,10 +1206,7 @@ static void do_video_out(AVFormatContext *s, #if !CONFIG_AVFILTER if (ost->video_resample) { final_picture = &ost->pict_tmp; - if( ost->resample_height != ist->st->codec->height - || ost->resample_width != ist->st->codec->width - || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { - + if (resample_changed) { /* initialize a new scaler context */ sws_freeContext(ost->img_resample_ctx); sws_flags = av_get_int(sws_opts, "sws_flags", NULL); From c438c9075655951a8de2c41af1f76574cf22ab85 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 16 Apr 2011 23:18:22 +0200 Subject: [PATCH 014/172] ffmpeg: reformat resample condition code in transcode() Signed-off-by: Stefano Sabatini --- ffmpeg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index af5fa641ea..eadfc8072d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2284,9 +2284,9 @@ static int transcode(AVFormatContext **output_files, fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); ffmpeg_exit(1); } - ost->video_resample = (codec->width != icodec->width || - codec->height != icodec->height || - (codec->pix_fmt != icodec->pix_fmt)); + ost->video_resample = codec->width != icodec->width || + codec->height != icodec->height || + codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); From 22fa406f384eb9d825b1d691332e1f928750d55b Mon Sep 17 00:00:00 2001 From: Peter Belkner Date: Tue, 19 Apr 2011 11:58:53 +0200 Subject: [PATCH 015/172] Check avcodec_alloc_frame() failure. Signed-off-by: Michael Niedermayer --- libavcodec/libmp3lame.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index db0bc8259c..086c7dc7f9 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -69,7 +69,11 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx) avctx->frame_size = lame_get_framesize(s->gfp); - avctx->coded_frame= avcodec_alloc_frame(); + if(!(avctx->coded_frame= avcodec_alloc_frame())) { + lame_close(s->gfp); + + return AVERROR(ENOMEM); + } avctx->coded_frame->key_frame= 1; return 0; From 39e69d0b88bf521097feeaa2ec5f390dd1e27723 Mon Sep 17 00:00:00 2001 From: Peter Belkner Date: Tue, 19 Apr 2011 12:00:01 +0200 Subject: [PATCH 016/172] 32bit libmp3lame support. --- libavcodec/libmp3lame.c | 70 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 086c7dc7f9..5cfb122903 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -34,6 +34,10 @@ typedef struct Mp3AudioContext { int stereo; uint8_t buffer[BUFFER_SIZE]; int buffer_index; + struct { + int *left; + int *right; + } s32_data; } Mp3AudioContext; static av_cold int MP3lame_encode_init(AVCodecContext *avctx) @@ -76,6 +80,19 @@ static av_cold int MP3lame_encode_init(AVCodecContext *avctx) } avctx->coded_frame->key_frame= 1; + if(AV_SAMPLE_FMT_S32 == avctx->sample_fmt && s->stereo) { + int nelem = 2 * avctx->frame_size; + + if(! (s->s32_data.left = av_malloc(nelem * sizeof(int)))) { + av_freep(&avctx->coded_frame); + lame_close(s->gfp); + + return AVERROR(ENOMEM); + } + + s->s32_data.right = s->s32_data.left + avctx->frame_size; + } + return 0; err_close: @@ -150,7 +167,45 @@ static int MP3lame_encode_frame(AVCodecContext *avctx, /* lame 3.91 dies on '1-channel interleaved' data */ - if(data){ + if(!data){ + lame_result= lame_encode_flush( + s->gfp, + s->buffer + s->buffer_index, + BUFFER_SIZE - s->buffer_index + ); +#if 2147483647 == INT_MAX + }else if(AV_SAMPLE_FMT_S32 == avctx->sample_fmt){ + if (s->stereo) { + int32_t *rp = data; + int32_t *mp = rp + 2*avctx->frame_size; + int *wpl = s->s32_data.left; + int *wpr = s->s32_data.right; + + while (rp < mp) { + *wpl++ = *rp++; + *wpr++ = *rp++; + } + + lame_result = lame_encode_buffer_int( + s->gfp, + s->s32_data.left, + s->s32_data.right, + avctx->frame_size, + s->buffer + s->buffer_index, + BUFFER_SIZE - s->buffer_index + ); + } else { + lame_result = lame_encode_buffer_int( + s->gfp, + data, + data, + avctx->frame_size, + s->buffer + s->buffer_index, + BUFFER_SIZE - s->buffer_index + ); + } +#endif + }else{ if (s->stereo) { lame_result = lame_encode_buffer_interleaved( s->gfp, @@ -169,12 +224,6 @@ static int MP3lame_encode_frame(AVCodecContext *avctx, BUFFER_SIZE - s->buffer_index ); } - }else{ - lame_result= lame_encode_flush( - s->gfp, - s->buffer + s->buffer_index, - BUFFER_SIZE - s->buffer_index - ); } if(lame_result < 0){ @@ -210,6 +259,7 @@ static av_cold int MP3lame_encode_close(AVCodecContext *avctx) { Mp3AudioContext *s = avctx->priv_data; + av_freep(&s->s32_data.left); av_freep(&avctx->coded_frame); lame_close(s->gfp); @@ -226,7 +276,11 @@ AVCodec ff_libmp3lame_encoder = { MP3lame_encode_frame, MP3lame_encode_close, .capabilities= CODEC_CAP_DELAY, - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16, +#if 2147483647 == INT_MAX + AV_SAMPLE_FMT_S32, +#endif + AV_SAMPLE_FMT_NONE}, .supported_samplerates= sSampleRates, .long_name= NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"), }; From 484a3308903d3e9a01cbc0ba2504ef3f5850c076 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 17 Apr 2011 17:19:05 +0200 Subject: [PATCH 017/172] pad: make the filter parametric Address trac issue #61. Signed-off-by: Stefano Sabatini --- doc/filters.texi | 57 ++++++++++++++++++++- libavfilter/avfilter.h | 2 +- libavfilter/vf_pad.c | 114 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 163 insertions(+), 10 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index b36ae07112..b38abf308d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -985,6 +985,39 @@ given coordinates @var{x}, @var{y}. It accepts the following parameters: @var{width}:@var{height}:@var{x}:@var{y}:@var{color}. +The parameters @var{width}, @var{height}, @var{x}, and @var{y} are +expressions containing the following constants: + +@table @option +@item E, PI, PHI +the corresponding mathematical approximated values for e +(euler number), pi (greek PI), phi (golden ratio) + +@item in_w, in_h +the input video width and heigth + +@item iw, ih +same as @var{in_w} and @var{in_h} + +@item out_w, out_h +the output width and heigth, that is the size of the padded area as +specified by the @var{width} and @var{height} expressions + +@item ow, oh +same as @var{out_w} and @var{out_h} + +@item x, y +x and y offsets as specified by the @var{x} and @var{y} +expressions, or NAN if not yet specified + +@item a +input display aspect ratio, same as @var{iw} / @var{ih} + +@item hsub, vsub +horizontal and vertical chroma subsample values. For example for the +pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. +@end table + Follows the description of the accepted parameters. @table @option @@ -994,6 +1027,9 @@ Specify the size of the output image with the paddings added. If the value for @var{width} or @var{height} is 0, the corresponding input size is used for the output. +The @var{width} expression can reference the value set by the +@var{height} expression, and viceversa. + The default value of @var{width} and @var{height} is 0. @item x, y @@ -1001,6 +1037,9 @@ The default value of @var{width} and @var{height} is 0. Specify the offsets where to place the input image in the padded area with respect to the top/left border of the output image. +The @var{x} expression can reference the value set by the @var{y} +expression, and viceversa. + The default value of @var{x} and @var{y} is 0. @item color @@ -1012,13 +1051,29 @@ The default value of @var{color} is "black". @end table -For example: +Some examples follow: @example # Add paddings with color "violet" to the input video. Output video # size is 640x480, the top-left corner of the input video is placed at # column 0, row 40. pad=640:480:0:40:violet + +# pad the input to get an output with dimensions increased bt 3/2, +# and put the input video at the center of the padded area +pad="3/2*iw:3/2*ih:(ow-iw)/2:(oh-ih)/2" + +# pad the input to get a squared output with size equal to the maximum +# value between the input width and height, and put the input video at +# the center of the padded area +pad="max(iw\,ih):ow:(ow-iw)/2:(oh-ih)/2" + +# pad the input to get a final w/h ratio of 16:9 +pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2" + +# double output size and put the input video in the bottom-right +# corner of the output padded area +pad="2*iw:2*ih:ow-iw:oh-ih" @end example @section pixdesctest diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 16c761ad52..f7c85daed3 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -27,7 +27,7 @@ #define LIBAVFILTER_VERSION_MAJOR 1 #define LIBAVFILTER_VERSION_MINOR 79 -#define LIBAVFILTER_VERSION_MICRO 0 +#define LIBAVFILTER_VERSION_MICRO 1 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 492b08eb68..e41ebe8964 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -25,6 +25,8 @@ */ #include "avfilter.h" +#include "libavutil/avstring.h" +#include "libavutil/eval.h" #include "libavutil/pixdesc.h" #include "libavutil/colorspace.h" #include "libavutil/avassert.h" @@ -32,6 +34,38 @@ #include "libavutil/parseutils.h" #include "drawutils.h" +static const char *var_names[] = { + "PI", + "PHI", + "E", + "in_w", "iw", + "in_h", "ih", + "out_w", "ow", + "out_h", "oh", + "x", + "y", + "a", + "hsub", + "vsub", + NULL +}; + +enum var_name { + VAR_PI, + VAR_PHI, + VAR_E, + VAR_IN_W, VAR_IW, + VAR_IN_H, VAR_IH, + VAR_OUT_W, VAR_OW, + VAR_OUT_H, VAR_OH, + VAR_X, + VAR_Y, + VAR_A, + VAR_HSUB, + VAR_VSUB, + VARS_NB +}; + static int query_formats(AVFilterContext *ctx) { static const enum PixelFormat pix_fmts[] = { @@ -58,6 +92,11 @@ typedef struct { int x, y; ///< offsets of the input area with respect to the padded area int in_w, in_h; ///< width and height for the padded input video, which has to be aligned to the chroma values in order to avoid chroma issues + char w_expr[256]; ///< width expression string + char h_expr[256]; ///< height expression string + char x_expr[256]; ///< width expression string + char y_expr[256]; ///< height expression string + uint8_t color[4]; ///< color expressed either in YUVA or RGBA colorspace for the padding area uint8_t *line[4]; int line_step[4]; @@ -70,18 +109,18 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) PadContext *pad = ctx->priv; char color_string[128] = "black"; + av_strlcpy(pad->w_expr, "iw", sizeof(pad->w_expr)); + av_strlcpy(pad->h_expr, "ih", sizeof(pad->h_expr)); + av_strlcpy(pad->x_expr, "0" , sizeof(pad->w_expr)); + av_strlcpy(pad->y_expr, "0" , sizeof(pad->h_expr)); + if (args) - sscanf(args, "%d:%d:%d:%d:%s", &pad->w, &pad->h, &pad->x, &pad->y, color_string); + sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255s", + pad->w_expr, pad->h_expr, pad->x_expr, pad->y_expr, color_string); if (av_parse_color(pad->color, color_string, -1, ctx) < 0) return AVERROR(EINVAL); - /* sanity check params */ - if (pad->w < 0 || pad->h < 0) { - av_log(ctx, AV_LOG_ERROR, "Negative size values are not acceptable.\n"); - return AVERROR(EINVAL); - } - return 0; } @@ -102,11 +141,64 @@ static int config_input(AVFilterLink *inlink) PadContext *pad = ctx->priv; const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]; uint8_t rgba_color[4]; - int is_packed_rgba; + int ret, is_packed_rgba; + double var_values[VARS_NB], res; + char *expr; pad->hsub = pix_desc->log2_chroma_w; pad->vsub = pix_desc->log2_chroma_h; + var_values[VAR_PI] = M_PI; + var_values[VAR_PHI] = M_PHI; + var_values[VAR_E] = M_E; + var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w; + var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; + var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; + var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; + var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_HSUB] = 1<hsub; + var_values[VAR_VSUB] = 2<vsub; + + /* evaluate width and height */ + av_expr_parse_and_eval(&res, (expr = pad->w_expr), + var_names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, ctx); + pad->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; + if ((ret = av_expr_parse_and_eval(&res, (expr = pad->h_expr), + var_names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) + goto eval_fail; + pad->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res; + /* evaluate the width again, as it may depend on the evaluated output height */ + if ((ret = av_expr_parse_and_eval(&res, (expr = pad->w_expr), + var_names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) + goto eval_fail; + pad->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; + + /* evaluate x and y */ + av_expr_parse_and_eval(&res, (expr = pad->x_expr), + var_names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, ctx); + pad->x = var_values[VAR_X] = res; + if ((ret = av_expr_parse_and_eval(&res, (expr = pad->y_expr), + var_names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) + goto eval_fail; + pad->y = var_values[VAR_Y] = res; + /* evaluate x again, as it may depend on the evaluated y value */ + if ((ret = av_expr_parse_and_eval(&res, (expr = pad->x_expr), + var_names, var_values, + NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) + goto eval_fail; + pad->x = var_values[VAR_X] = res; + + /* sanity check params */ + if (pad->w < 0 || pad->h < 0 || pad->x < 0 || pad->y < 0) { + av_log(ctx, AV_LOG_ERROR, "Negative values are not acceptable.\n"); + return AVERROR(EINVAL); + } + if (!pad->w) pad->w = inlink->w; if (!pad->h) @@ -140,6 +232,12 @@ static int config_input(AVFilterLink *inlink) } return 0; + +eval_fail: + av_log(NULL, AV_LOG_ERROR, + "Error when evaluating the expression '%s'\n", expr); + return ret; + } static int config_output(AVFilterLink *outlink) From e61b83d29e1b273a7d4d1d982aac68cf26a0a3ee Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Fri, 15 Apr 2011 19:18:04 +0200 Subject: [PATCH 018/172] Ogg: add support for Xiph's CELT (Opus) codec. This patch also introduces CODEC_ID_CELT. Signed-off-by: Nicolas George --- libavcodec/avcodec.h | 1 + libavformat/Makefile | 1 + libavformat/oggdec.c | 1 + libavformat/oggdec.h | 1 + libavformat/oggparsecelt.c | 99 ++++++++++++++++++++++++++++++++++++++ libavformat/utils.c | 3 +- 6 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 libavformat/oggparsecelt.c diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 07bae8747d..33ae03121b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -342,6 +342,7 @@ enum CodecID { CODEC_ID_BINKAUDIO_DCT, CODEC_ID_AAC_LATM, CODEC_ID_QDMC, + CODEC_ID_CELT, /* subtitle codecs */ CODEC_ID_DVD_SUBTITLE= 0x17000, diff --git a/libavformat/Makefile b/libavformat/Makefile index 18f8c492d0..20b50920a4 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -164,6 +164,7 @@ OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o riff.o OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o riff.o OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o riff.o OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ + oggparsecelt.o \ oggparsedirac.o \ oggparseflac.o \ oggparseogm.o \ diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 100519b93a..2f76ec8871 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -45,6 +45,7 @@ static const struct ogg_codec * const ogg_codecs[] = { &ff_vorbis_codec, &ff_theora_codec, &ff_flac_codec, + &ff_celt_codec, &ff_old_dirac_codec, &ff_old_flac_codec, &ff_ogm_video_codec, diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index 7d66cd5638..82efd97aec 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -98,6 +98,7 @@ struct ogg { #define OGG_FLAG_BOS 2 #define OGG_FLAG_EOS 4 +extern const struct ogg_codec ff_celt_codec; extern const struct ogg_codec ff_dirac_codec; extern const struct ogg_codec ff_flac_codec; extern const struct ogg_codec ff_ogm_audio_codec; diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c new file mode 100644 index 0000000000..b3c8660c9d --- /dev/null +++ b/libavformat/oggparsecelt.c @@ -0,0 +1,99 @@ +/* + * Xiph CELT / Opus parser for Ogg + * Copyright (c) 2011 Nicolas George + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "avformat.h" +#include "oggdec.h" +#include "libavutil/intreadwrite.h" + +struct oggcelt_private { + int extra_headers_left; +}; + +static int celt_header(AVFormatContext *s, int idx) +{ + struct ogg *ogg = s->priv_data; + struct ogg_stream *os = ogg->streams + idx; + AVStream *st = s->streams[idx]; + struct oggcelt_private *priv = os->private; + uint8_t *p = os->buf + os->pstart; + + if (os->psize == 60 && + !memcmp(p, ff_celt_codec.magic, ff_celt_codec.magicsize)) { + + /* Main header */ + + uint32_t version, header_size, sample_rate, nb_channels, frame_size; + uint32_t overlap, bytes_per_packet, extra_headers; + uint8_t *extradata; + + extradata = av_malloc(2 * sizeof(uint32_t) + + FF_INPUT_BUFFER_PADDING_SIZE); + priv = av_malloc(sizeof(struct oggcelt_private)); + if (!extradata || !priv) { + av_free(extradata); + av_free(priv); + return AVERROR(ENOMEM); + } + version = AV_RL32(p + 28); + header_size = AV_RL32(p + 32); /* unused */ + sample_rate = AV_RL32(p + 36); + nb_channels = AV_RL32(p + 40); + frame_size = AV_RL32(p + 44); + overlap = AV_RL32(p + 48); + bytes_per_packet = AV_RL32(p + 52); /* unused */ + extra_headers = AV_RL32(p + 56); + av_free(os->private); + av_free(st->codec->extradata); + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_CELT; + st->codec->sample_rate = sample_rate; + st->codec->channels = nb_channels; + st->codec->frame_size = frame_size; + st->codec->sample_fmt = AV_SAMPLE_FMT_S16; + st->codec->extradata = extradata; + st->codec->extradata_size = 2 * sizeof(uint32_t); + if (sample_rate) + av_set_pts_info(st, 64, 1, sample_rate); + priv->extra_headers_left = 1 + extra_headers; + os->private = priv; + AV_WL32(extradata + 0, overlap); + AV_WL32(extradata + 4, version); + return 1; + + } else if(priv && priv->extra_headers_left) { + + /* Extra headers (vorbiscomment) */ + + ff_vorbis_comment(s, &st->metadata, p, os->psize); + priv->extra_headers_left--; + return 1; + + } else { + return 0; + } +} + +const struct ogg_codec ff_celt_codec = { + .magic = "CELT ", + .magicsize = 8, + .header = celt_header, +}; diff --git a/libavformat/utils.c b/libavformat/utils.c index 6421a33456..ffb114d5e9 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2084,7 +2084,8 @@ static int has_codec_parameters(AVCodecContext *enc) enc->codec_id == CODEC_ID_MP1 || enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || - enc->codec_id == CODEC_ID_SPEEX)) + enc->codec_id == CODEC_ID_SPEEX || + enc->codec_id == CODEC_ID_CELT)) return 0; break; case AVMEDIA_TYPE_VIDEO: From 151cd4f98225c0c5cab8fb29e1dbc0719f7f67e3 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 19 Apr 2011 08:47:59 +0200 Subject: [PATCH 019/172] pcm: Add const to cast in ENCODE macro. This fixes a lot of warnings of the sort: libavcodec/pcm.c:105: warning: cast discards qualifiers from pointer target type --- libavcodec/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index e2a733495e..9100646179 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -71,7 +71,7 @@ static av_cold int pcm_encode_close(AVCodecContext *avctx) * @param offset Sample value offset */ #define ENCODE(type, endian, src, dst, n, shift, offset) \ - samples_##type = (type*)src; \ + samples_##type = (const type*) src; \ for(;n>0;n--) { \ register type v = (*samples_##type++ >> shift) + offset; \ bytestream_put_##endian(&dst, v); \ From aad2f2f477d6804f5f79ccce55b3d7f54b00f715 Mon Sep 17 00:00:00 2001 From: Kostya Date: Mon, 18 Apr 2011 05:32:14 +0000 Subject: [PATCH 020/172] document introduction of side data in APIchanges this should've been written earlier, sorry Signed-off-by: Anton Khirnov --- doc/APIchanges | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index 11a8b51b7e..2c0d58519e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -12,6 +12,11 @@ libavutil: 2009-03-08 API changes, most recent first: +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 + 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 From 761ad429680637411882552921a9d5acb6aff59e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:25:54 +0100 Subject: [PATCH 021/172] lavf: remove FF_API_MAX_STREAMS cruft --- ffmpeg.c | 2 -- ffserver.c | 6 ------ libavformat/avformat.h | 8 -------- libavformat/mms.c | 4 ---- libavformat/mpegts.c | 5 ----- libavformat/nutdec.c | 4 ---- libavformat/utils.c | 8 -------- libavformat/version.h | 3 --- 8 files changed, 40 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 80d2cca2b7..1ffb21102b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -106,9 +106,7 @@ typedef struct AVChapterMap { static const OptionDef options[]; #define MAX_FILES 100 -#if !FF_API_MAX_STREAMS #define MAX_STREAMS 1024 /* arbitrary sanity check value */ -#endif #define FFM_PACKET_SIZE 4096 //XXX a duplicate of the line in ffm.h diff --git a/ffserver.c b/ffserver.c index 36cd9cedbc..079be03994 100644 --- a/ffserver.c +++ b/ffserver.c @@ -95,9 +95,7 @@ static const char *http_state[] = { "RTSP_SEND_PACKET", }; -#if !FF_API_MAX_STREAMS #define MAX_STREAMS 20 -#endif #define IOBUFFER_INIT_SIZE 8192 @@ -2944,11 +2942,9 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, snprintf(avc->filename, 1024, "rtp://0.0.0.0"); } -#if !FF_API_MAX_STREAMS if (avc->nb_streams >= INT_MAX/sizeof(*avc->streams) || !(avc->streams = av_malloc(avc->nb_streams * sizeof(*avc->streams)))) goto sdp_done; -#endif if (avc->nb_streams >= INT_MAX/sizeof(*avs) || !(avs = av_malloc(avc->nb_streams * sizeof(*avs)))) goto sdp_done; @@ -2961,9 +2957,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, av_sdp_create(&avc, 1, *pbuffer, 2048); sdp_done: -#if !FF_API_MAX_STREAMS av_free(avc->streams); -#endif av_metadata_free(&avc->metadata); av_free(avc); av_free(avs); diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 55808f13b8..6f7b6a5116 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -672,10 +672,6 @@ typedef struct AVChapter { AVMetadata *metadata; } AVChapter; -#if FF_API_MAX_STREAMS -#define MAX_STREAMS 20 -#endif - /** * Format I/O context. * New fields can be added to the end with minor version bumps. @@ -691,11 +687,7 @@ typedef struct AVFormatContext { void *priv_data; AVIOContext *pb; unsigned int nb_streams; -#if FF_API_MAX_STREAMS - AVStream *streams[MAX_STREAMS]; -#else AVStream **streams; -#endif char filename[1024]; /**< input or output filename */ /* stream info */ int64_t timestamp; diff --git a/libavformat/mms.c b/libavformat/mms.c index 5796663253..192e7039af 100644 --- a/libavformat/mms.c +++ b/libavformat/mms.c @@ -24,11 +24,7 @@ #include "asf.h" #include "libavutil/intreadwrite.h" -#if FF_API_MAX_STREAMS -#define MMS_MAX_STREAMS MAX_STREAMS -#else #define MMS_MAX_STREAMS 256 /**< arbitrary sanity check value */ -#endif int ff_mms_read_header(MMSContext *mms, uint8_t *buf, const int size) { diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 62e9dcbbd9..d7f2c0c957 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -675,11 +675,6 @@ static int mpegts_push_data(MpegTSFilter *filter, code == 0x1be) /* padding_stream */ goto skip; -#if FF_API_MAX_STREAMS - if (!pes->st && pes->stream->nb_streams == MAX_STREAMS) - goto skip; -#endif - /* stream not present in PMT */ if (!pes->st) { pes->st = av_new_stream(ts->stream, pes->pid); diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index d3804f2993..0a1ed554e3 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -30,11 +30,7 @@ #undef NDEBUG #include -#if FF_API_MAX_STREAMS -#define NUT_MAX_STREAMS MAX_STREAMS -#else #define NUT_MAX_STREAMS 256 /* arbitrary sanity check value */ -#endif static int get_str(AVIOContext *bc, char *string, unsigned int maxlen){ unsigned int len= ffio_read_varlen(bc); diff --git a/libavformat/utils.c b/libavformat/utils.c index 6b38e66bc5..a1336179f1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2660,13 +2660,6 @@ AVStream *av_new_stream(AVFormatContext *s, int id) { AVStream *st; int i; - -#if FF_API_MAX_STREAMS - if (s->nb_streams >= MAX_STREAMS){ - av_log(s, AV_LOG_ERROR, "Too many streams\n"); - return NULL; - } -#else AVStream **streams; if (s->nb_streams >= INT_MAX/sizeof(*streams)) @@ -2675,7 +2668,6 @@ AVStream *av_new_stream(AVFormatContext *s, int id) if (!streams) return NULL; s->streams = streams; -#endif st = av_mallocz(sizeof(AVStream)); if (!st) diff --git a/libavformat/version.h b/libavformat/version.h index b21938aaef..bf1ae5bff8 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -41,9 +41,6 @@ * Those FF_API_* defines are not part of public API. * They may change, break or disappear at any time. */ -#ifndef FF_API_MAX_STREAMS -#define FF_API_MAX_STREAMS (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_OLD_METADATA #define FF_API_OLD_METADATA (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From 575c18da1b5053e244ccbfbcced176b5a63dbb25 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:30:16 +0100 Subject: [PATCH 022/172] lavf: remove FF_API_OLD_METADATA cruft --- libavformat/Makefile | 1 - libavformat/avformat.h | 39 --------- libavformat/metadata.c | 7 -- libavformat/metadata.h | 5 -- libavformat/metadata_compat.c | 148 ---------------------------------- libavformat/options.c | 4 - libavformat/utils.c | 21 ----- libavformat/version.h | 3 - 8 files changed, 228 deletions(-) delete mode 100644 libavformat/metadata_compat.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 0bf2633d66..5e029ed96b 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -10,7 +10,6 @@ OBJS = allformats.o \ id3v1.o \ id3v2.o \ metadata.o \ - metadata_compat.o \ options.o \ os_support.o \ sdp.o \ diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6f7b6a5116..f3e4fe4842 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -133,20 +133,6 @@ typedef struct AVMetadataConv AVMetadataConv; AVMetadataTag * av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags); -#if FF_API_OLD_METADATA -/** - * Set the given tag in *pm, overwriting an existing tag. - * - * @param pm pointer to a pointer to a metadata struct. If *pm is NULL - * a metadata struct is allocated and put in *pm. - * @param key tag key to add to *pm (will be av_strduped) - * @param value tag value to add to *pm (will be av_strduped) - * @return >= 0 on success otherwise an error code <0 - * @deprecated Use av_metadata_set2() instead. - */ -attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const char *value); -#endif - /** * Set the given tag in *pm, overwriting an existing tag. * @@ -544,10 +530,6 @@ typedef struct AVStream { */ int64_t duration; -#if FF_API_OLD_METADATA - attribute_deprecated char language[4]; /**< ISO 639-2/B 3-letter language code (empty string if undefined) */ -#endif - /* av_read_frame() support */ enum AVStreamParseType need_parsing; struct AVCodecParserContext *parser; @@ -567,10 +549,6 @@ typedef struct AVStream { attribute_deprecated int64_t unused[4+1]; #endif -#if FF_API_OLD_METADATA - attribute_deprecated char *filename; /**< source filename of the stream */ -#endif - int disposition; /**< AV_DISPOSITION_* bit field */ AVProbeData probe_data; @@ -648,10 +626,6 @@ typedef struct AVStream { */ typedef struct AVProgram { int id; -#if FF_API_OLD_METADATA - attribute_deprecated char *provider_name; ///< network name for DVB streams - attribute_deprecated char *name; ///< service name for DVB streams -#endif int flags; enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller unsigned int *stream_index; @@ -666,9 +640,6 @@ typedef struct AVChapter { int id; ///< unique ID to identify the chapter AVRational time_base; ///< time base in which the start/end timestamps are specified int64_t start, end; ///< chapter start/end time in time_base units -#if FF_API_OLD_METADATA - attribute_deprecated char *title; ///< chapter title -#endif AVMetadata *metadata; } AVChapter; @@ -691,16 +662,6 @@ typedef struct AVFormatContext { char filename[1024]; /**< input or output filename */ /* stream info */ int64_t timestamp; -#if FF_API_OLD_METADATA - attribute_deprecated char title[512]; - attribute_deprecated char author[512]; - attribute_deprecated char copyright[512]; - attribute_deprecated char comment[512]; - attribute_deprecated char album[512]; - attribute_deprecated int year; /**< ID3 year, 0 if none */ - attribute_deprecated int track; /**< track number, 0 if none */ - attribute_deprecated char genre[32]; /**< ID3 genre */ -#endif int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ /* private data for pts handling (do not modify directly). */ diff --git a/libavformat/metadata.c b/libavformat/metadata.c index 36a9342882..f0275462fe 100644 --- a/libavformat/metadata.c +++ b/libavformat/metadata.c @@ -86,13 +86,6 @@ int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int fl return 0; } -#if FF_API_OLD_METADATA -int av_metadata_set(AVMetadata **pm, const char *key, const char *value) -{ - return av_metadata_set2(pm, key, value, 0); -} -#endif - #if FF_API_OLD_METADATA2 void av_metadata_conv(AVFormatContext *ctx, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv) diff --git a/libavformat/metadata.h b/libavformat/metadata.h index 43eace8e39..09066b8c8d 100644 --- a/libavformat/metadata.h +++ b/libavformat/metadata.h @@ -43,11 +43,6 @@ struct AVMetadataConv{ typedef struct AVMetadataConv AVMetadataConv; #endif -#if FF_API_OLD_METADATA -void ff_metadata_demux_compat(AVFormatContext *s); -void ff_metadata_mux_compat(AVFormatContext *s); -#endif - void ff_metadata_conv(AVMetadata **pm, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv); void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv, diff --git a/libavformat/metadata_compat.c b/libavformat/metadata_compat.c deleted file mode 100644 index bb73258707..0000000000 --- a/libavformat/metadata_compat.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2009 Aurelien Jacobs - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include "avformat.h" -#include "metadata.h" -#include "libavutil/avstring.h" - -#if FF_API_OLD_METADATA - -#define SIZE_OFFSET(x) sizeof(((AVFormatContext*)0)->x),offsetof(AVFormatContext,x) - -static const struct { - const char name[16]; - int size; - int offset; -} compat_tab[] = { - { "title", SIZE_OFFSET(title) }, - { "author", SIZE_OFFSET(author) }, - { "copyright", SIZE_OFFSET(copyright) }, - { "comment", SIZE_OFFSET(comment) }, - { "album", SIZE_OFFSET(album) }, - { "year", SIZE_OFFSET(year) }, - { "track", SIZE_OFFSET(track) }, - { "genre", SIZE_OFFSET(genre) }, - - { "artist", SIZE_OFFSET(author) }, - { "creator", SIZE_OFFSET(author) }, - { "written_by", SIZE_OFFSET(author) }, - { "lead_performer", SIZE_OFFSET(author) }, - { "composer", SIZE_OFFSET(author) }, - { "performer", SIZE_OFFSET(author) }, - { "description", SIZE_OFFSET(comment) }, - { "albumtitle", SIZE_OFFSET(album) }, - { "date", SIZE_OFFSET(year) }, - { "date_written", SIZE_OFFSET(year) }, - { "date_released", SIZE_OFFSET(year) }, - { "tracknumber", SIZE_OFFSET(track) }, - { "part_number", SIZE_OFFSET(track) }, -}; - -void ff_metadata_demux_compat(AVFormatContext *ctx) -{ - AVMetadata *m; - int i, j; - - if ((m = ctx->metadata)) - for (j=0; jcount; j++) - for (i=0; ielems[j].key, compat_tab[i].name)) { - int *ptr = (int *)((char *)ctx+compat_tab[i].offset); - if (*ptr) continue; - if (compat_tab[i].size > sizeof(int)) - av_strlcpy((char *)ptr, m->elems[j].value, compat_tab[i].size); - else - *ptr = atoi(m->elems[j].value); - } - - for (i=0; inb_chapters; i++) - if ((m = ctx->chapters[i]->metadata)) - for (j=0; jcount; j++) - if (!strcasecmp(m->elems[j].key, "title")) { - av_free(ctx->chapters[i]->title); - ctx->chapters[i]->title = av_strdup(m->elems[j].value); - } - - for (i=0; inb_programs; i++) - if ((m = ctx->programs[i]->metadata)) - for (j=0; jcount; j++) { - if (!strcasecmp(m->elems[j].key, "name")) { - av_free(ctx->programs[i]->name); - ctx->programs[i]->name = av_strdup(m->elems[j].value); - } - if (!strcasecmp(m->elems[j].key, "provider_name")) { - av_free(ctx->programs[i]->provider_name); - ctx->programs[i]->provider_name = av_strdup(m->elems[j].value); - } - } - - for (i=0; inb_streams; i++) - if ((m = ctx->streams[i]->metadata)) - for (j=0; jcount; j++) { - if (!strcasecmp(m->elems[j].key, "language")) - av_strlcpy(ctx->streams[i]->language, m->elems[j].value, 4); - if (!strcasecmp(m->elems[j].key, "filename")) { - av_free(ctx->streams[i]->filename); - ctx->streams[i]->filename= av_strdup(m->elems[j].value); - } - } -} - - -#define FILL_METADATA(s, key, value) { \ - if (!av_metadata_get(s->metadata, #key, NULL, 0)) \ - av_metadata_set2(&s->metadata, #key, value, 0); \ - } -#define FILL_METADATA_STR(s, key) { \ - if (s->key && *s->key) FILL_METADATA(s, key, s->key); } -#define FILL_METADATA_INT(s, key) { \ - char number[10]; \ - snprintf(number, sizeof(number), "%d", s->key); \ - if(s->key) FILL_METADATA(s, key, number) } - -void ff_metadata_mux_compat(AVFormatContext *ctx) -{ - int i; - - if (ctx->metadata && ctx->metadata->count > 0) - return; - - FILL_METADATA_STR(ctx, title); - FILL_METADATA_STR(ctx, author); - FILL_METADATA_STR(ctx, copyright); - FILL_METADATA_STR(ctx, comment); - FILL_METADATA_STR(ctx, album); - FILL_METADATA_INT(ctx, year); - FILL_METADATA_INT(ctx, track); - FILL_METADATA_STR(ctx, genre); - for (i=0; inb_chapters; i++) - FILL_METADATA_STR(ctx->chapters[i], title); - for (i=0; inb_programs; i++) { - FILL_METADATA_STR(ctx->programs[i], name); - FILL_METADATA_STR(ctx->programs[i], provider_name); - } - for (i=0; inb_streams; i++) { - FILL_METADATA_STR(ctx->streams[i], language); - FILL_METADATA_STR(ctx->streams[i], filename); - } -} - -#endif /* FF_API_OLD_METADATA */ diff --git a/libavformat/options.c b/libavformat/options.c index beaafd8ab3..40edcec762 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -50,10 +50,6 @@ static const AVOption options[]={ {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOPARSE, INT_MIN, INT_MAX, D, "fflags"}, {"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"}, {"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_RTP_HINT, INT_MIN, INT_MAX, E, "fflags"}, -#if FF_API_OLD_METADATA -{"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E}, -{"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E}, -#endif {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 5*AV_TIME_BASE, 0, INT_MAX, D}, {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D}, {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D}, diff --git a/libavformat/utils.c b/libavformat/utils.c index a1336179f1..cf8f9fae63 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -508,10 +508,6 @@ int av_open_input_stream(AVFormatContext **ic_ptr, if (pb && !ic->data_offset) ic->data_offset = avio_tell(ic->pb); -#if FF_API_OLD_METADATA - ff_metadata_demux_compat(ic); -#endif - ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; *ic_ptr = ic; @@ -2617,18 +2613,11 @@ void avformat_free_context(AVFormatContext *s) av_free(st->codec->extradata); av_free(st->codec->subtitle_header); av_free(st->codec); -#if FF_API_OLD_METADATA - av_free(st->filename); -#endif av_free(st->priv_data); av_free(st->info); av_free(st); } for(i=s->nb_programs-1; i>=0; i--) { -#if FF_API_OLD_METADATA - av_freep(&s->programs[i]->provider_name); - av_freep(&s->programs[i]->name); -#endif av_metadata_free(&s->programs[i]->metadata); av_freep(&s->programs[i]->stream_index); av_freep(&s->programs[i]); @@ -2636,9 +2625,6 @@ void avformat_free_context(AVFormatContext *s) av_freep(&s->programs); av_freep(&s->priv_data); while(s->nb_chapters--) { -#if FF_API_OLD_METADATA - av_free(s->chapters[s->nb_chapters]->title); -#endif av_metadata_free(&s->chapters[s->nb_chapters]->metadata); av_free(s->chapters[s->nb_chapters]); } @@ -2747,9 +2733,6 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int6 return NULL; dynarray_add(&s->chapters, &s->nb_chapters, chapter); } -#if FF_API_OLD_METADATA - av_free(chapter->title); -#endif av_metadata_set2(&chapter->metadata, "title", title, 0); chapter->id = id; chapter->time_base= time_base; @@ -2887,10 +2870,6 @@ int av_write_header(AVFormatContext *s) return AVERROR(ENOMEM); } -#if FF_API_OLD_METADATA - ff_metadata_mux_compat(s); -#endif - /* set muxer identification string */ if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) { av_metadata_set2(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0); diff --git a/libavformat/version.h b/libavformat/version.h index bf1ae5bff8..8f0316b05d 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -41,9 +41,6 @@ * Those FF_API_* defines are not part of public API. * They may change, break or disappear at any time. */ -#ifndef FF_API_OLD_METADATA -#define FF_API_OLD_METADATA (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_OLD_METADATA2 #define FF_API_OLD_METADATA2 (LIBAVFORMAT_VERSION_MAJOR < 54) #endif From 468644f6c185c23affcb36939192b03cd166797f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:32:59 +0100 Subject: [PATCH 023/172] lavf: remove FF_API_URL_RESETBUF cruft --- libavformat/avio.h | 8 -------- libavformat/aviobuf.c | 11 ----------- libavformat/version.h | 3 --- 3 files changed, 22 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index f4674a43be..213baaab72 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -542,14 +542,6 @@ int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); -#if FF_API_URL_RESETBUF -/** Reset the buffer for reading or writing. - * @note Will drop any data currently in the buffer without transmitting it. - * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY - * to set up the buffer for writing. */ -int url_resetbuf(AVIOContext *s, int flags); -#endif - /** * @defgroup open_modes URL open modes * The flags argument to avio_open must be one of the following diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index cde5f269b5..2bacedbaa7 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -38,9 +38,7 @@ #define SHORT_SEEK_THRESHOLD 4096 static void fill_buffer(AVIOContext *s); -#if !FF_API_URL_RESETBUF static int url_resetbuf(AVIOContext *s, int flags); -#endif int ffio_init_context(AVIOContext *s, unsigned char *buffer, @@ -878,18 +876,9 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size) return 0; } -#if FF_API_URL_RESETBUF -int url_resetbuf(AVIOContext *s, int flags) -#else static int url_resetbuf(AVIOContext *s, int flags) -#endif { -#if FF_API_URL_RESETBUF - if (flags & AVIO_RDWR) - return AVERROR(EINVAL); -#else assert(flags == AVIO_WRONLY || flags == AVIO_RDONLY); -#endif if (flags & AVIO_WRONLY) { s->buf_end = s->buffer + s->buffer_size; diff --git a/libavformat/version.h b/libavformat/version.h index 8f0316b05d..aecc9618d1 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -47,9 +47,6 @@ #ifndef FF_API_URL_CLASS #define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) #endif -#ifndef FF_API_URL_RESETBUF -#define FF_API_URL_RESETBUF (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_REGISTER_PROTOCOL #define FF_API_REGISTER_PROTOCOL (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From dcd4a7b62f16793c33fa459889e581286d6ccdd6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:36:18 +0100 Subject: [PATCH 024/172] lavf: remove FF_API_REGISTER_PROTOCOL cruft --- libavformat/avio.c | 23 ----------------------- libavformat/avio.h | 16 ---------------- libavformat/version.h | 3 --- 3 files changed, 42 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index cb923a726e..c1c2027d5d 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -84,29 +84,6 @@ int ffurl_register_protocol(URLProtocol *protocol, int size) return 0; } -#if FF_API_REGISTER_PROTOCOL -/* The layout of URLProtocol as of when major was bumped to 52 */ -struct URLProtocol_compat { - const char *name; - int (*url_open)(URLContext *h, const char *filename, int flags); - int (*url_read)(URLContext *h, unsigned char *buf, int size); - int (*url_write)(URLContext *h, unsigned char *buf, int size); - int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); - int (*url_close)(URLContext *h); - struct URLProtocol *next; -}; - -int av_register_protocol(URLProtocol *protocol) -{ - return ffurl_register_protocol(protocol, sizeof(struct URLProtocol_compat)); -} - -int register_protocol(URLProtocol *protocol) -{ - return ffurl_register_protocol(protocol, sizeof(struct URLProtocol_compat)); -} -#endif - static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up, const char *filename, int flags) { diff --git a/libavformat/avio.h b/libavformat/avio.h index 213baaab72..82c2cece07 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -373,22 +373,6 @@ int avio_check(const char *url, int flags); */ void avio_set_interrupt_cb(int (*interrupt_cb)(void)); -#if FF_API_REGISTER_PROTOCOL -extern URLProtocol *first_protocol; -#endif - -#if FF_API_REGISTER_PROTOCOL -/** - * @deprecated Use av_register_protocol() instead. - */ -attribute_deprecated int register_protocol(URLProtocol *protocol); - -/** - * @deprecated Use av_register_protocol2() instead. - */ -attribute_deprecated int av_register_protocol(URLProtocol *protocol); -#endif - /** * Allocate and initialize an AVIOContext for buffered I/O. It must be later * freed with av_free(). diff --git a/libavformat/version.h b/libavformat/version.h index aecc9618d1..ef253599e4 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -47,9 +47,6 @@ #ifndef FF_API_URL_CLASS #define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) #endif -#ifndef FF_API_REGISTER_PROTOCOL -#define FF_API_REGISTER_PROTOCOL (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_GUESS_FORMAT #define FF_API_GUESS_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From 61573bf1ba50dc8828d0e87d913389fbcff48509 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:38:05 +0100 Subject: [PATCH 025/172] lavf: remove FF_API_GUESS_FORMAT cruft --- libavformat/avformat.h | 12 ------------ libavformat/utils.c | 29 ----------------------------- libavformat/version.h | 3 --- 3 files changed, 44 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index f3e4fe4842..dae56c6037 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -862,18 +862,6 @@ attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename); /* utils.c */ void av_register_input_format(AVInputFormat *format); void av_register_output_format(AVOutputFormat *format); -#if FF_API_GUESS_FORMAT -attribute_deprecated AVOutputFormat *guess_stream_format(const char *short_name, - const char *filename, - const char *mime_type); - -/** - * @deprecated Use av_guess_format() instead. - */ -attribute_deprecated AVOutputFormat *guess_format(const char *short_name, - const char *filename, - const char *mime_type); -#endif /** * Return the output format in the list of registered output formats diff --git a/libavformat/utils.c b/libavformat/utils.c index cf8f9fae63..80700d4b2b 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -200,14 +200,6 @@ static int match_format(const char *name, const char *names) return !strcasecmp(name, names); } -#if FF_API_GUESS_FORMAT -AVOutputFormat *guess_format(const char *short_name, const char *filename, - const char *mime_type) -{ - return av_guess_format(short_name, filename, mime_type); -} -#endif - AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { @@ -243,27 +235,6 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename, return fmt_found; } -#if FF_API_GUESS_FORMAT -AVOutputFormat *guess_stream_format(const char *short_name, const char *filename, - const char *mime_type) -{ - AVOutputFormat *fmt = av_guess_format(short_name, filename, mime_type); - - if (fmt) { - AVOutputFormat *stream_fmt; - char stream_format_name[64]; - - snprintf(stream_format_name, sizeof(stream_format_name), "%s_stream", fmt->name); - stream_fmt = av_guess_format(stream_format_name, NULL, NULL); - - if (stream_fmt) - fmt = stream_fmt; - } - - return fmt; -} -#endif - enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type){ if(type == AVMEDIA_TYPE_VIDEO){ diff --git a/libavformat/version.h b/libavformat/version.h index ef253599e4..182bfb7814 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -47,9 +47,6 @@ #ifndef FF_API_URL_CLASS #define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) #endif -#ifndef FF_API_GUESS_FORMAT -#define FF_API_GUESS_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_UDP_GET_FILE #define FF_API_UDP_GET_FILE (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From c4efa7c22960588ff5163a1cfe026b48b8f6ec41 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:39:11 +0100 Subject: [PATCH 026/172] lavf: remove FF_API_UDP_GET_FILE cruft --- libavformat/avio.h | 4 ---- libavformat/udp.c | 5 +---- libavformat/version.h | 3 --- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 82c2cece07..2502711be5 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -605,10 +605,6 @@ int avio_open_dyn_buf(AVIOContext **s); */ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); -#if FF_API_UDP_GET_FILE -int udp_get_file_handle(URLContext *h); -#endif - /** * Iterate through names of available protocols. * diff --git a/libavformat/udp.c b/libavformat/udp.c index b881ff95fd..e16dc4c7e0 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -292,10 +292,7 @@ int ff_udp_get_local_port(URLContext *h) * streams at the same time. * @param h media file context */ -#if !FF_API_UDP_GET_FILE -static -#endif -int udp_get_file_handle(URLContext *h) +static int udp_get_file_handle(URLContext *h) { UDPContext *s = h->priv_data; return s->udp_fd; diff --git a/libavformat/version.h b/libavformat/version.h index 182bfb7814..50421495bb 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -47,9 +47,6 @@ #ifndef FF_API_URL_CLASS #define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) #endif -#ifndef FF_API_UDP_GET_FILE -#define FF_API_UDP_GET_FILE (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_URL_SPLIT #define FF_API_URL_SPLIT (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From 5048e36c994663f7f4977efc48c3eec601654e5a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:40:25 +0100 Subject: [PATCH 027/172] lavf: remove FF_API_URL_SPLIT cruft --- libavformat/internal.h | 12 ------------ libavformat/utils.c | 18 ------------------ libavformat/version.h | 3 --- 3 files changed, 33 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 9bc23402a4..6f1305ce25 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -79,18 +79,6 @@ void ff_read_frame_flush(AVFormatContext *s); /** Get the current time since NTP epoch in microseconds. */ uint64_t ff_ntp_time(void); -#if FF_API_URL_SPLIT -/** - * @deprecated use av_url_split() instead - */ -void ff_url_split(char *proto, int proto_size, - char *authorization, int authorization_size, - char *hostname, int hostname_size, - int *port_ptr, - char *path, int path_size, - const char *url); -#endif - /** * Assemble a URL string from components. This is the reverse operation * of av_url_split. diff --git a/libavformat/utils.c b/libavformat/utils.c index 80700d4b2b..91e0ddca2d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3517,24 +3517,6 @@ void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base); } -#if FF_API_URL_SPLIT -attribute_deprecated -void ff_url_split(char *proto, int proto_size, - char *authorization, int authorization_size, - char *hostname, int hostname_size, - int *port_ptr, - char *path, int path_size, - const char *url) -{ - av_url_split(proto, proto_size, - authorization, authorization_size, - hostname, hostname_size, - port_ptr, - path, path_size, - url); -} -#endif - void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, diff --git a/libavformat/version.h b/libavformat/version.h index 50421495bb..9b8192d96d 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -47,9 +47,6 @@ #ifndef FF_API_URL_CLASS #define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) #endif -#ifndef FF_API_URL_SPLIT -#define FF_API_URL_SPLIT (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_ALLOC_FORMAT_CONTEXT #define FF_API_ALLOC_FORMAT_CONTEXT (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From 4df001d77f8f39d2914b21f14ca2236b0ffd6a48 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:42:38 +0100 Subject: [PATCH 028/172] lavf: remove FF_API_ALLOC_FORMAT_CONTEXT cruft --- libavformat/avformat.h | 7 ------- libavformat/options.c | 7 ------- libavformat/version.h | 3 --- 3 files changed, 17 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index dae56c6037..3e47285267 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1043,13 +1043,6 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, int buf_size, AVFormatParameters *ap); -#if FF_API_ALLOC_FORMAT_CONTEXT -/** - * @deprecated Use avformat_alloc_context() instead. - */ -attribute_deprecated AVFormatContext *av_alloc_format_context(void); -#endif - /** * Allocate an AVFormatContext. * avformat_free_context() can be used to free the context and everything diff --git a/libavformat/options.c b/libavformat/options.c index 40edcec762..2192ff6575 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -84,10 +84,3 @@ AVFormatContext *avformat_alloc_context(void) ic->av_class = &av_format_context_class; return ic; } - -#if FF_API_ALLOC_FORMAT_CONTEXT -AVFormatContext *av_alloc_format_context(void) -{ - return avformat_alloc_context(); -} -#endif diff --git a/libavformat/version.h b/libavformat/version.h index 9b8192d96d..f87665c205 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -47,9 +47,6 @@ #ifndef FF_API_URL_CLASS #define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) #endif -#ifndef FF_API_ALLOC_FORMAT_CONTEXT -#define FF_API_ALLOC_FORMAT_CONTEXT (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_PARSE_FRAME_PARAM #define FF_API_PARSE_FRAME_PARAM (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From 58d5ff0abf657fe0ec3564433ebbde9fc8f71ffd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:44:04 +0100 Subject: [PATCH 029/172] lavf: remove FF_API_PARSE_FRAME_PARAM cruft --- libavformat/avformat.h | 16 ---------------- libavformat/utils.c | 18 ------------------ libavformat/version.h | 3 --- 3 files changed, 37 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 3e47285267..289834627a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1409,22 +1409,6 @@ void av_dump_format(AVFormatContext *ic, const char *url, int is_output); -#if FF_API_PARSE_FRAME_PARAM -/** - * Parse width and height out of string str. - * @deprecated Use av_parse_video_frame_size instead. - */ -attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, - const char *str); - -/** - * Convert framerate from a string to a fraction. - * @deprecated Use av_parse_video_frame_rate instead. - */ -attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, - const char *arg); -#endif - #if FF_API_PARSE_DATE /** * Parse datestr and return a corresponding number of microseconds. diff --git a/libavformat/utils.c b/libavformat/utils.c index 91e0ddca2d..d2f70e17e6 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3320,24 +3320,6 @@ void av_dump_format(AVFormatContext *ic, av_free(printed); } -#if FF_API_PARSE_FRAME_PARAM -#include "libavutil/parseutils.h" - -int parse_image_size(int *width_ptr, int *height_ptr, const char *str) -{ - return av_parse_video_size(width_ptr, height_ptr, str); -} - -int parse_frame_rate(int *frame_rate_num, int *frame_rate_den, const char *arg) -{ - AVRational frame_rate; - int ret = av_parse_video_rate(&frame_rate, arg); - *frame_rate_num= frame_rate.num; - *frame_rate_den= frame_rate.den; - return ret; -} -#endif - int64_t av_gettime(void) { struct timeval tv; diff --git a/libavformat/version.h b/libavformat/version.h index f87665c205..08dc566425 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -47,9 +47,6 @@ #ifndef FF_API_URL_CLASS #define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) #endif -#ifndef FF_API_PARSE_FRAME_PARAM -#define FF_API_PARSE_FRAME_PARAM (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_READ_SEEK #define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) #endif From fc2d3a19c54ad6b272eb7d5142148a01568a9b77 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:45:30 +0100 Subject: [PATCH 030/172] lavf: remove FF_API_LAVF_UNUSED cruft --- libavformat/avformat.h | 9 --------- libavformat/version.h | 3 --- 2 files changed, 12 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 289834627a..d507c2048b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -545,10 +545,6 @@ typedef struct AVStream { int64_t nb_frames; ///< number of frames in this stream if known or 0 -#if FF_API_LAVF_UNUSED - attribute_deprecated int64_t unused[4+1]; -#endif - int disposition; /**< AV_DISPOSITION_* bit field */ AVProbeData probe_data; @@ -701,11 +697,6 @@ typedef struct AVFormatContext { /* av_read_frame() support */ AVStream *cur_st; -#if FF_API_LAVF_UNUSED - const uint8_t *cur_ptr_deprecated; - int cur_len_deprecated; - AVPacket cur_pkt_deprecated; -#endif /* av_seek_frame() support */ int64_t data_offset; /**< offset of the first packet */ diff --git a/libavformat/version.h b/libavformat/version.h index 08dc566425..484ebecb9c 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -50,9 +50,6 @@ #ifndef FF_API_READ_SEEK #define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_LAVF_UNUSED -#define FF_API_LAVF_UNUSED (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_PARAMETERS_CODEC_ID #define FF_API_PARAMETERS_CODEC_ID (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From 583f6c67b6edfb6a6202944b8ba98b483826a1ec Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:46:12 +0100 Subject: [PATCH 031/172] lavf: remove FF_API_PARAMETERS_CODEC_ID cruft --- libavformat/avformat.h | 4 ---- libavformat/version.h | 3 --- 2 files changed, 7 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index d507c2048b..4ed791b995 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -242,10 +242,6 @@ typedef struct AVFormatParameters { unsigned int initial_pause:1; /**< Do not begin to play the stream immediately (RTSP only). */ unsigned int prealloced_context:1; -#if FF_API_PARAMETERS_CODEC_ID - attribute_deprecated enum CodecID video_codec_id; - attribute_deprecated enum CodecID audio_codec_id; -#endif } AVFormatParameters; //! Demuxer will use avio_open, no opened file should be provided by the caller. diff --git a/libavformat/version.h b/libavformat/version.h index 484ebecb9c..11b8b0529f 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -50,9 +50,6 @@ #ifndef FF_API_READ_SEEK #define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_PARAMETERS_CODEC_ID -#define FF_API_PARAMETERS_CODEC_ID (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_FIRST_FORMAT #define FF_API_FIRST_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From b4c5acabb90cf8e69db2d9f3210d9fa8a7d55ec6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:47:18 +0100 Subject: [PATCH 032/172] lavf: remove FF_API_FIRST_FORMAT cruft --- libavformat/avformat.h | 5 ----- libavformat/utils.c | 10 ++-------- libavformat/version.h | 3 --- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 4ed791b995..568521311e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -820,11 +820,6 @@ typedef struct AVPacketList { struct AVPacketList *next; } AVPacketList; -#if FF_API_FIRST_FORMAT -attribute_deprecated extern AVInputFormat *first_iformat; -attribute_deprecated extern AVOutputFormat *first_oformat; -#endif - /** * If f is NULL, returns the first registered input format, * if f is non-NULL, returns the next registered input format after f diff --git a/libavformat/utils.c b/libavformat/utils.c index d2f70e17e6..1359bd3d05 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -115,15 +115,9 @@ static void av_frac_add(AVFrac *f, int64_t incr) } /** head of registered input format linked list */ -#if !FF_API_FIRST_FORMAT -static -#endif -AVInputFormat *first_iformat = NULL; +static AVInputFormat *first_iformat = NULL; /** head of registered output format linked list */ -#if !FF_API_FIRST_FORMAT -static -#endif -AVOutputFormat *first_oformat = NULL; +static AVOutputFormat *first_oformat = NULL; AVInputFormat *av_iformat_next(AVInputFormat *f) { diff --git a/libavformat/version.h b/libavformat/version.h index 11b8b0529f..9499fd6e38 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -50,9 +50,6 @@ #ifndef FF_API_READ_SEEK #define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_FIRST_FORMAT -#define FF_API_FIRST_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_SYMVER #define FF_API_SYMVER (LIBAVFORMAT_VERSION_MAJOR < 53) #endif From 5763e63913940f8d2d2eb8750931e5f12dd2a481 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:49:12 +0100 Subject: [PATCH 033/172] lavf: remove FF_API_SYMVER cruft --- libavformat/utils.c | 32 -------------------------------- libavformat/version.h | 3 --- 2 files changed, 35 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 1359bd3d05..1e70b4f592 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -260,38 +260,6 @@ AVInputFormat *av_find_input_format(const char *short_name) return NULL; } -#if FF_API_SYMVER && CONFIG_SHARED && HAVE_SYMVER -FF_SYMVER(void, av_destruct_packet_nofree, (AVPacket *pkt), "LIBAVFORMAT_52") -{ - av_destruct_packet_nofree(pkt); -} - -FF_SYMVER(void, av_destruct_packet, (AVPacket *pkt), "LIBAVFORMAT_52") -{ - av_destruct_packet(pkt); -} - -FF_SYMVER(int, av_new_packet, (AVPacket *pkt, int size), "LIBAVFORMAT_52") -{ - return av_new_packet(pkt, size); -} - -FF_SYMVER(int, av_dup_packet, (AVPacket *pkt), "LIBAVFORMAT_52") -{ - return av_dup_packet(pkt); -} - -FF_SYMVER(void, av_free_packet, (AVPacket *pkt), "LIBAVFORMAT_52") -{ - av_free_packet(pkt); -} - -FF_SYMVER(void, av_init_packet, (AVPacket *pkt), "LIBAVFORMAT_52") -{ - av_log(NULL, AV_LOG_WARNING, "Diverting av_*_packet function calls to libavcodec. Recompile to improve performance\n"); - av_init_packet(pkt); -} -#endif int av_get_packet(AVIOContext *s, AVPacket *pkt, int size) { diff --git a/libavformat/version.h b/libavformat/version.h index 9499fd6e38..735891a1eb 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -50,9 +50,6 @@ #ifndef FF_API_READ_SEEK #define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_SYMVER -#define FF_API_SYMVER (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_OLD_AVIO #define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 54) #endif From 7f804085f1be53fac1a28a962c1e34873981b131 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 12:53:28 +0100 Subject: [PATCH 034/172] lavf: remove FF_API_URL_CLASS cruft. --- libavformat/avio.c | 4 --- libavformat/avio.h | 2 -- libavformat/rtmpproto.c | 59 ++++++++++++++++++----------------------- libavformat/version.h | 3 --- 4 files changed, 26 insertions(+), 42 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index c1c2027d5d..4f8acb01ff 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -31,7 +31,6 @@ #endif #include "url.h" -#if FF_API_URL_CLASS /** @name Logging context. */ /*@{*/ static const char *urlcontext_to_name(void *ptr) @@ -44,7 +43,6 @@ static const AVOption options[] = {{NULL}}; static const AVClass urlcontext_class = { "URLContext", urlcontext_to_name, options, LIBAVUTIL_VERSION_INT }; /*@}*/ -#endif static int default_interrupt_cb(void); @@ -99,9 +97,7 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up, err = AVERROR(ENOMEM); goto fail; } -#if FF_API_URL_CLASS uc->av_class = &urlcontext_class; -#endif uc->filename = (char *) &uc[1]; strcpy(uc->filename, filename); uc->prot = up; diff --git a/libavformat/avio.h b/libavformat/avio.h index 2502711be5..62ea42ca96 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -101,9 +101,7 @@ typedef struct { * @deprecated This struct will be made private */ typedef struct URLContext { -#if FF_API_URL_CLASS const AVClass *av_class; ///< information for av_log(). Set by url_open(). -#endif struct URLProtocol *prot; int flags; int is_streamed; /**< true if streamed (no seek possible), default = false */ diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 9fc5196b2c..3413b62c8b 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -38,13 +38,6 @@ #include "rtmppkt.h" #include "url.h" -/* we can't use av_log() with URLContext yet... */ -#if FF_API_URL_CLASS -#define LOG_CONTEXT s -#else -#define LOG_CONTEXT NULL -#endif - //#define DEBUG /** RTMP protocol handler state */ @@ -166,7 +159,7 @@ static void gen_release_stream(URLContext *s, RTMPContext *rt) ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 29 + strlen(rt->playpath)); - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Releasing stream...\n"); + av_log(s, AV_LOG_DEBUG, "Releasing stream...\n"); p = pkt.data; ff_amf_write_string(&p, "releaseStream"); ff_amf_write_number(&p, 2.0); @@ -189,7 +182,7 @@ static void gen_fcpublish_stream(URLContext *s, RTMPContext *rt) ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 25 + strlen(rt->playpath)); - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "FCPublish stream...\n"); + av_log(s, AV_LOG_DEBUG, "FCPublish stream...\n"); p = pkt.data; ff_amf_write_string(&p, "FCPublish"); ff_amf_write_number(&p, 3.0); @@ -212,7 +205,7 @@ static void gen_fcunpublish_stream(URLContext *s, RTMPContext *rt) ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 27 + strlen(rt->playpath)); - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "UnPublishing stream...\n"); + av_log(s, AV_LOG_DEBUG, "UnPublishing stream...\n"); p = pkt.data; ff_amf_write_string(&p, "FCUnpublish"); ff_amf_write_number(&p, 5.0); @@ -232,7 +225,7 @@ static void gen_create_stream(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Creating stream...\n"); + av_log(s, AV_LOG_DEBUG, "Creating stream...\n"); ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 25); p = pkt.data; @@ -254,7 +247,7 @@ static void gen_delete_stream(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Deleting stream...\n"); + av_log(s, AV_LOG_DEBUG, "Deleting stream...\n"); ff_rtmp_packet_create(&pkt, RTMP_SYSTEM_CHANNEL, RTMP_PT_INVOKE, 0, 34); p = pkt.data; @@ -276,7 +269,7 @@ static void gen_play(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Sending play command for '%s'\n", rt->playpath); + av_log(s, AV_LOG_DEBUG, "Sending play command for '%s'\n", rt->playpath); ff_rtmp_packet_create(&pkt, RTMP_VIDEO_CHANNEL, RTMP_PT_INVOKE, 0, 20 + strlen(rt->playpath)); pkt.extra = rt->main_channel_id; @@ -310,7 +303,7 @@ static void gen_publish(URLContext *s, RTMPContext *rt) RTMPPacket pkt; uint8_t *p; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Sending publish command for '%s'\n", rt->playpath); + av_log(s, AV_LOG_DEBUG, "Sending publish command for '%s'\n", rt->playpath); ff_rtmp_packet_create(&pkt, RTMP_SOURCE_CHANNEL, RTMP_PT_INVOKE, 0, 30 + strlen(rt->playpath)); pkt.extra = rt->main_channel_id; @@ -478,7 +471,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) int server_pos, client_pos; uint8_t digest[32]; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Handshaking...\n"); + av_log(s, AV_LOG_DEBUG, "Handshaking...\n"); av_lfg_init(&rnd, 0xDEADC0DE); // generate handshake packet - 1536 bytes of pseudorandom data @@ -489,16 +482,16 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) ffurl_write(rt->stream, tosend, RTMP_HANDSHAKE_PACKET_SIZE + 1); i = ffurl_read_complete(rt->stream, serverdata, RTMP_HANDSHAKE_PACKET_SIZE + 1); if (i != RTMP_HANDSHAKE_PACKET_SIZE + 1) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); + av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); return -1; } i = ffurl_read_complete(rt->stream, clientdata, RTMP_HANDSHAKE_PACKET_SIZE); if (i != RTMP_HANDSHAKE_PACKET_SIZE) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); + av_log(s, AV_LOG_ERROR, "Cannot read RTMP handshake response\n"); return -1; } - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Server version %d.%d.%d.%d\n", + av_log(s, AV_LOG_DEBUG, "Server version %d.%d.%d.%d\n", serverdata[5], serverdata[6], serverdata[7], serverdata[8]); if (rt->is_input && serverdata[5] >= 3) { @@ -506,7 +499,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) if (!server_pos) { server_pos = rtmp_validate_digest(serverdata + 1, 8); if (!server_pos) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Server response validating failed\n"); + av_log(s, AV_LOG_ERROR, "Server response validating failed\n"); return -1; } } @@ -518,7 +511,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) digest, 32, digest); if (memcmp(digest, clientdata + RTMP_HANDSHAKE_PACKET_SIZE - 32, 32)) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Signature mismatch\n"); + av_log(s, AV_LOG_ERROR, "Signature mismatch\n"); return -1; } @@ -552,13 +545,13 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) const uint8_t *data_end = pkt->data + pkt->data_size; #ifdef DEBUG - ff_rtmp_packet_dump(LOG_CONTEXT, pkt); + ff_rtmp_packet_dump(s, pkt); #endif switch (pkt->type) { case RTMP_PT_CHUNK_SIZE: if (pkt->data_size != 4) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, + av_log(s, AV_LOG_ERROR, "Chunk size change packet is not 4 bytes long (%d)\n", pkt->data_size); return -1; } @@ -566,10 +559,10 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size, rt->prev_pkt[1]); rt->chunk_size = AV_RB32(pkt->data); if (rt->chunk_size <= 0) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size); + av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size); return -1; } - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size); + av_log(s, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size); break; case RTMP_PT_PING: t = AV_RB16(pkt->data); @@ -578,12 +571,12 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) break; case RTMP_PT_CLIENT_BW: if (pkt->data_size < 4) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, + av_log(s, AV_LOG_ERROR, "Client bandwidth report packet is less than 4 bytes long (%d)\n", pkt->data_size); return -1; } - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Client bandwidth = %d\n", AV_RB32(pkt->data)); + av_log(s, AV_LOG_DEBUG, "Client bandwidth = %d\n", AV_RB32(pkt->data)); rt->client_report_size = AV_RB32(pkt->data) >> 1; break; case RTMP_PT_INVOKE: @@ -593,7 +586,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) if (!ff_amf_get_field_value(pkt->data + 9, data_end, "description", tmpstr, sizeof(tmpstr))) - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Server error: %s\n",tmpstr); + av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr); return -1; } else if (!memcmp(pkt->data, "\002\000\007_result", 10)) { switch (rt->state) { @@ -624,7 +617,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) case STATE_CONNECTING: //extract a number from the result if (pkt->data[10] || pkt->data[19] != 5 || pkt->data[20]) { - av_log(LOG_CONTEXT, AV_LOG_WARNING, "Unexpected reply on connect()\n"); + av_log(s, AV_LOG_WARNING, "Unexpected reply on connect()\n"); } else { rt->main_channel_id = (int) av_int2dbl(AV_RB64(pkt->data + 21)); } @@ -651,7 +644,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) if (!t && !strcmp(tmpstr, "error")) { if (!ff_amf_get_field_value(ptr, data_end, "description", tmpstr, sizeof(tmpstr))) - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Server error: %s\n",tmpstr); + av_log(s, AV_LOG_ERROR, "Server error: %s\n",tmpstr); return -1; } t = ff_amf_get_field_value(ptr, data_end, @@ -701,7 +694,7 @@ static int get_packet(URLContext *s, int for_header) } rt->bytes_read += ret; if (rt->bytes_read > rt->last_bytes_read + rt->client_report_size) { - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Sending bytes read report\n"); + av_log(s, AV_LOG_DEBUG, "Sending bytes read report\n"); gen_bytes_read(s, rt, rpkt.timestamp + 1); rt->last_bytes_read = rt->bytes_read; } @@ -822,7 +815,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); if (ffurl_open(&rt->stream, buf, AVIO_RDWR) < 0) { - av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot open connection %s\n", buf); + av_log(s, AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } @@ -866,7 +859,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) rt->bytes_read = 0; rt->last_bytes_read = 0; - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", + av_log(s, AV_LOG_DEBUG, "Proto = %s, path = %s, app = %s, fname = %s\n", proto, path, rt->app, rt->playpath); gen_connect(s, rt, proto, hostname, port); @@ -933,7 +926,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) const uint8_t *buf_temp = buf; if (size < 11) { - av_log(LOG_CONTEXT, AV_LOG_DEBUG, "FLV packet too small %d\n", size); + av_log(s, AV_LOG_DEBUG, "FLV packet too small %d\n", size); return 0; } diff --git a/libavformat/version.h b/libavformat/version.h index 735891a1eb..6396164212 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -44,9 +44,6 @@ #ifndef FF_API_OLD_METADATA2 #define FF_API_OLD_METADATA2 (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_URL_CLASS -#define FF_API_URL_CLASS (LIBAVFORMAT_VERSION_MAJOR >= 53) -#endif #ifndef FF_API_READ_SEEK #define FF_API_READ_SEEK (LIBAVFORMAT_VERSION_MAJOR < 54) #endif From df56d5833959cde9ce60ab43e2923eaaea3287b3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Apr 2011 20:10:10 +0200 Subject: [PATCH 035/172] lavf: remove FF_API_INDEX_BUILT cruft --- libavformat/avformat.h | 3 --- libavformat/version.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 568521311e..2567aabd5a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -696,9 +696,6 @@ typedef struct AVFormatContext { /* av_seek_frame() support */ int64_t data_offset; /**< offset of the first packet */ -#if FF_API_INDEX_BUILT - attribute_deprecated int index_built; -#endif int mux_rate; unsigned int packet_size; diff --git a/libavformat/version.h b/libavformat/version.h index 6396164212..01730183b2 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -50,9 +50,6 @@ #ifndef FF_API_OLD_AVIO #define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 54) #endif -#ifndef FF_API_INDEX_BUILT -#define FF_API_INDEX_BUILT (LIBAVFORMAT_VERSION_MAJOR < 53) -#endif #ifndef FF_API_DUMP_FORMAT #define FF_API_DUMP_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 54) #endif From 32b80696e0637ca7254c35e6195bdc9ebb2352e0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 13 Apr 2011 08:01:49 +0200 Subject: [PATCH 036/172] lavf: remove misc disabled cruft. --- libavformat/avio.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 62ea42ca96..c63b545d33 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -357,9 +357,6 @@ attribute_deprecated int url_exist(const char *url); * one call to another. Thus you should not trust the returned value, * unless you are sure that no other processes are accessing the * checked resource. - * - * @note This function is slightly broken until next major bump - * because of AVIO_RDONLY == 0. Don't use it until then. */ int avio_check(const char *url, int flags); @@ -530,15 +527,9 @@ int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); * constants, optionally ORed with other flags. * @{ */ -#if LIBAVFORMAT_VERSION_MAJOR < 53 -#define AVIO_RDONLY 0 /**< read-only */ -#define AVIO_WRONLY 1 /**< write-only */ -#define AVIO_RDWR 2 /**< read-write */ -#else #define AVIO_RDONLY 1 /**< read-only */ #define AVIO_WRONLY 2 /**< write-only */ #define AVIO_RDWR 4 /**< read-write */ -#endif /** * @} */ @@ -555,11 +546,7 @@ int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); * Warning: non-blocking protocols is work-in-progress; this flag may be * silently ignored. */ -#if LIBAVFORMAT_VERSION_MAJOR < 53 -#define AVIO_FLAG_NONBLOCK 4 -#else #define AVIO_FLAG_NONBLOCK 8 -#endif /** * Create and initialize a AVIOContext for accessing the From 42420e7b946272bc1e4b2aa2a95512c86db02831 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 14:43:53 +0100 Subject: [PATCH 037/172] lavc: remove the FF_API_MM_FLAGS cruft. --- libavcodec/avcodec.h | 19 ------------------- libavcodec/version.h | 3 --- 2 files changed, 22 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index df4e61798e..5d85b4122f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1740,25 +1740,6 @@ typedef struct AVCodecContext { */ unsigned dsp_mask; -#if FF_API_MM_FLAGS -#define FF_MM_FORCE AV_CPU_FLAG_FORCE -#define FF_MM_MMX AV_CPU_FLAG_MMX -#define FF_MM_3DNOW AV_CPU_FLAG_3DNOW -#define FF_MM_MMXEXT AV_CPU_FLAG_MMX2 -#define FF_MM_MMX2 AV_CPU_FLAG_MMX2 -#define FF_MM_SSE AV_CPU_FLAG_SSE -#define FF_MM_SSE2 AV_CPU_FLAG_SSE2 -#define FF_MM_SSE2SLOW AV_CPU_FLAG_SSE2SLOW -#define FF_MM_3DNOWEXT AV_CPU_FLAG_3DNOWEXT -#define FF_MM_SSE3 AV_CPU_FLAG_SSE3 -#define FF_MM_SSE3SLOW AV_CPU_FLAG_SSE3SLOW -#define FF_MM_SSSE3 AV_CPU_FLAG_SSSE3 -#define FF_MM_SSE4 AV_CPU_FLAG_SSE4 -#define FF_MM_SSE42 AV_CPU_FLAG_SSE42 -#define FF_MM_IWMMXT AV_CPU_FLAG_IWMMXT -#define FF_MM_ALTIVEC AV_CPU_FLAG_ALTIVEC -#endif - /** * bits per sample/pixel from the demuxer (needed for huffyuv). * - encoding: Set by libavcodec. diff --git a/libavcodec/version.h b/libavcodec/version.h index 7e5347404d..2b9856ce8b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_MM_FLAGS -#define FF_API_MM_FLAGS (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_OPT_SHOW #define FF_API_OPT_SHOW (LIBAVCODEC_VERSION_MAJOR < 53) #endif From 20d33ee8b1d2cf5ba4b4d4a81db0ff7b4a125dd3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 14:45:22 +0100 Subject: [PATCH 038/172] lavc: remove the FF_API_OPT_SHOW cruft. --- libavcodec/opt.c | 7 ------- libavcodec/opt.h | 6 ------ libavcodec/version.h | 3 --- 3 files changed, 16 deletions(-) diff --git a/libavcodec/opt.c b/libavcodec/opt.c index f41fae0ba1..3b89a3013c 100644 --- a/libavcodec/opt.c +++ b/libavcodec/opt.c @@ -80,10 +80,3 @@ const AVOption *av_set_string(void *obj, const char *name, const char *val){ return o; } #endif - -#if FF_API_OPT_SHOW -int av_opt_show(void *obj, void *av_log_obj){ - return av_opt_show2(obj, av_log_obj, - AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); -} -#endif diff --git a/libavcodec/opt.h b/libavcodec/opt.h index cf54354096..ece54aad24 100644 --- a/libavcodec/opt.h +++ b/libavcodec/opt.h @@ -45,11 +45,5 @@ attribute_deprecated const AVOption *av_set_string(void *obj, const char *name, */ attribute_deprecated const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc); #endif -#if FF_API_OPT_SHOW -/** - * @deprecated Use av_opt_show2() instead. - */ -attribute_deprecated int av_opt_show(void *obj, void *av_log_obj); -#endif #endif /* AVCODEC_OPT_H */ diff --git a/libavcodec/version.h b/libavcodec/version.h index 2b9856ce8b..08574f784b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_OPT_SHOW -#define FF_API_OPT_SHOW (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_AUDIO_OLD #define FF_API_AUDIO_OLD (LIBAVCODEC_VERSION_MAJOR < 53) #endif From 9b4f1cdb6a7e838c0261109e8a6262e78657ee7b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 14:48:00 +0100 Subject: [PATCH 039/172] lavc: remove the FF_API_AUDIO_OLD cruft. --- libavcodec/avcodec.h | 27 --------------------------- libavcodec/resample.c | 11 ----------- libavcodec/utils.c | 14 -------------- libavcodec/version.h | 3 --- 4 files changed, 55 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 5d85b4122f..cf3664a973 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3227,14 +3227,6 @@ struct AVResampleContext; typedef struct ReSampleContext ReSampleContext; -#if FF_API_AUDIO_OLD -/** - * @deprecated Use av_audio_resample_init() instead. - */ -attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels, - int output_rate, int input_rate); -#endif - /** * Initialize audio resampling context. * @@ -3706,25 +3698,6 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, */ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); -#if FF_API_AUDIO_OLD -/** - * Decode an audio frame from buf into samples. - * Wrapper function which calls avcodec_decode_audio3. - * - * @deprecated Use avcodec_decode_audio3 instead. - * @param avctx the codec context - * @param[out] samples the output buffer - * @param[in,out] frame_size_ptr the output buffer size in bytes - * @param[in] buf the input buffer - * @param[in] buf_size the input buffer size in bytes - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. - */ -attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - const uint8_t *buf, int buf_size); -#endif - /** * Decode the audio frame of size avpkt->size from avpkt->data into samples. * Some decoders may support multiple frames in a single AVPacket, such diff --git a/libavcodec/resample.c b/libavcodec/resample.c index 8e666894ac..2185a11ad7 100644 --- a/libavcodec/resample.c +++ b/libavcodec/resample.c @@ -218,17 +218,6 @@ ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, return s; } -#if FF_API_AUDIO_OLD -ReSampleContext *audio_resample_init(int output_channels, int input_channels, - int output_rate, int input_rate) -{ - return av_audio_resample_init(output_channels, input_channels, - output_rate, input_rate, - AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16, - TAPS, 10, 0, 0.8); -} -#endif - /* resample audio. 'nb_samples' is the number of input samples */ /* XXX: optimize it ! */ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 6d31254afb..e90be4614d 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -679,20 +679,6 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi return ret; } -#if FF_API_AUDIO_OLD -int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - const uint8_t *buf, int buf_size) -{ - AVPacket avpkt; - av_init_packet(&avpkt); - avpkt.data = buf; - avpkt.size = buf_size; - - return avcodec_decode_audio3(avctx, samples, frame_size_ptr, &avpkt); -} -#endif - int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) diff --git a/libavcodec/version.h b/libavcodec/version.h index 08574f784b..8c891e248e 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_AUDIO_OLD -#define FF_API_AUDIO_OLD (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_VIDEO_OLD #define FF_API_VIDEO_OLD (LIBAVCODEC_VERSION_MAJOR < 53) #endif From e89e5afdd04a0f081ecc38b528c1147f204027d7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 14:48:39 +0100 Subject: [PATCH 040/172] lavc: remove the FF_API_VIDEO_OLD cruft. --- libavcodec/avcodec.h | 19 ------------------- libavcodec/utils.c | 16 ---------------- libavcodec/version.h | 3 --- 3 files changed, 38 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index cf3664a973..78dd20822a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3741,25 +3741,6 @@ int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt); -#if FF_API_VIDEO_OLD -/** - * Decode a video frame from buf into picture. - * Wrapper function which calls avcodec_decode_video2. - * - * @deprecated Use avcodec_decode_video2 instead. - * @param avctx the codec context - * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * @param[in] buf the input buffer - * @param[in] buf_size the size of the input buffer in bytes - * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. - */ -attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - const uint8_t *buf, int buf_size); -#endif - /** * Decode the video frame of size avpkt->size from avpkt->data into picture. * Some decoders may support multiple frames in a single AVPacket, such diff --git a/libavcodec/utils.c b/libavcodec/utils.c index e90be4614d..89bd4a1f55 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -631,22 +631,6 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, return ret; } -#if FF_API_VIDEO_OLD -int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - const uint8_t *buf, int buf_size) -{ - AVPacket avpkt; - av_init_packet(&avpkt); - avpkt.data = buf; - avpkt.size = buf_size; - // HACK for CorePNG to decode as normal PNG by default - avpkt.flags = AV_PKT_FLAG_KEY; - - return avcodec_decode_video2(avctx, picture, got_picture_ptr, &avpkt); -} -#endif - int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) diff --git a/libavcodec/version.h b/libavcodec/version.h index 8c891e248e..2d460b9744 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_VIDEO_OLD -#define FF_API_VIDEO_OLD (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_SUBTITLE_OLD #define FF_API_SUBTITLE_OLD (LIBAVCODEC_VERSION_MAJOR < 53) #endif From db4d3a7421ec70de0d5ccd8a9f99b46b5c780d23 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 14:50:06 +0100 Subject: [PATCH 041/172] lavc: remove the FF_API_SUBTITLE_OLD cruft. --- libavcodec/avcodec.h | 9 --------- libavcodec/utils.c | 14 -------------- libavcodec/version.h | 3 --- 3 files changed, 26 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 78dd20822a..c47b0065e7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3785,15 +3785,6 @@ int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt); -#if FF_API_SUBTITLE_OLD -/* Decode a subtitle message. Return -1 if error, otherwise return the - * number of bytes used. If no subtitle could be decompressed, - * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ -attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - const uint8_t *buf, int buf_size); -#endif - /** * Decode a subtitle message. * Return a negative value on error, otherwise return the number of bytes used. diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 89bd4a1f55..aa2e55693c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -692,20 +692,6 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa return ret; } -#if FF_API_SUBTITLE_OLD -int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - const uint8_t *buf, int buf_size) -{ - AVPacket avpkt; - av_init_packet(&avpkt); - avpkt.data = buf; - avpkt.size = buf_size; - - return avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, &avpkt); -} -#endif - int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) diff --git a/libavcodec/version.h b/libavcodec/version.h index 2d460b9744..d3dd04f169 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_SUBTITLE_OLD -#define FF_API_SUBTITLE_OLD (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_USE_LPC #define FF_API_USE_LPC (LIBAVCODEC_VERSION_MAJOR < 53) #endif From 01a4259b8db344586b371528973439109f3e2ace Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 14:51:50 +0100 Subject: [PATCH 042/172] lavc: remove the FF_API_USE_LPC cruft. --- libavcodec/avcodec.h | 10 ---------- libavcodec/flacenc.c | 11 ----------- libavcodec/options.c | 3 --- libavcodec/version.h | 3 --- 4 files changed, 27 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c47b0065e7..3eac5672b1 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2531,16 +2531,6 @@ typedef struct AVCodecContext { int compression_level; #define FF_COMPRESSION_DEFAULT -1 -#if FF_API_USE_LPC - /** - * Sets whether to use LPC mode - used by FLAC encoder. - * - encoding: Set by user. - * - decoding: unused - * @deprecated Deprecated in favor of lpc_type and lpc_passes. - */ - int use_lpc; -#endif - /** * LPC coefficient precision - used by FLAC encoder * - encoding: Set by user. diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index d93bfb5be4..f13d5801e2 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -285,17 +285,6 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level]; /* set compression option overrides from AVCodecContext */ -#if FF_API_USE_LPC - /* for compatibility with deprecated AVCodecContext.use_lpc */ - if (avctx->use_lpc == 0) { - s->options.lpc_type = AV_LPC_TYPE_FIXED; - } else if (avctx->use_lpc == 1) { - s->options.lpc_type = AV_LPC_TYPE_LEVINSON; - } else if (avctx->use_lpc > 1) { - s->options.lpc_type = AV_LPC_TYPE_CHOLESKY; - s->options.lpc_passes = avctx->use_lpc - 1; - } -#endif if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) { if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) { av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type); diff --git a/libavcodec/options.c b/libavcodec/options.c index 5856f96754..2f9d7d93c7 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -396,9 +396,6 @@ static const AVOption options[]={ {"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"}, {"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E}, {"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, FF_COMPRESSION_DEFAULT, INT_MIN, INT_MAX, V|A|E}, -#if FF_API_USE_LPC -{"use_lpc", "sets whether to use LPC mode (FLAC)", OFFSET(use_lpc), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, -#endif {"lpc_coeff_precision", "LPC coefficient precision (FLAC)", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E}, {"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, {"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, diff --git a/libavcodec/version.h b/libavcodec/version.h index d3dd04f169..5c81e3a671 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_USE_LPC -#define FF_API_USE_LPC (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_SET_STRING_OLD #define FF_API_SET_STRING_OLD (LIBAVCODEC_VERSION_MAJOR < 53) #endif From 41d0eb1c81c0d266824dfdbd040a54a6afeec81a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 14:58:59 +0100 Subject: [PATCH 043/172] lavc: remove the FF_API_SET_STRING_OLD cruft. --- cmdutils.c | 2 +- ffmpeg.c | 2 +- ffplay.c | 2 +- ffprobe.c | 2 +- ffserver.c | 2 +- libavcodec/opt.c | 16 --------------- libavcodec/opt.h | 49 -------------------------------------------- libavcodec/version.h | 3 --- libswscale/options.c | 2 +- 9 files changed, 6 insertions(+), 74 deletions(-) delete mode 100644 libavcodec/opt.h diff --git a/cmdutils.c b/cmdutils.c index cc10b48e30..f1cbd55373 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -38,7 +38,7 @@ #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/eval.h" -#include "libavcodec/opt.h" +#include "libavutil/opt.h" #include "cmdutils.h" #include "version.h" #if CONFIG_NETWORK diff --git a/ffmpeg.c b/ffmpeg.c index 1ffb21102b..f5244d98fd 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -34,7 +34,7 @@ #include "libavformat/avformat.h" #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" -#include "libavcodec/opt.h" +#include "libavutil/opt.h" #include "libavcodec/audioconvert.h" #include "libavutil/audioconvert.h" #include "libavutil/parseutils.h" diff --git a/ffplay.c b/ffplay.c index bd8a985eb5..766d5caf9c 100644 --- a/ffplay.c +++ b/ffplay.c @@ -35,7 +35,7 @@ #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libavcodec/audioconvert.h" -#include "libavcodec/opt.h" +#include "libavutil/opt.h" #include "libavcodec/avfft.h" #if CONFIG_AVFILTER diff --git a/ffprobe.c b/ffprobe.c index 6c672e7623..cc3699bf9b 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -23,7 +23,7 @@ #include "libavformat/avformat.h" #include "libavcodec/avcodec.h" -#include "libavcodec/opt.h" +#include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavdevice/avdevice.h" #include "cmdutils.h" diff --git a/ffserver.c b/ffserver.c index 079be03994..ec8b773c26 100644 --- a/ffserver.c +++ b/ffserver.c @@ -40,7 +40,7 @@ #include "libavutil/lfg.h" #include "libavutil/random_seed.h" #include "libavutil/parseutils.h" -#include "libavcodec/opt.h" +#include "libavutil/opt.h" #include #include #include diff --git a/libavcodec/opt.c b/libavcodec/opt.c index 3b89a3013c..f2bff96380 100644 --- a/libavcodec/opt.c +++ b/libavcodec/opt.c @@ -64,19 +64,3 @@ FF_SYMVER(void, av_opt_set_defaults2, (void *s, int mask, int flags), "LIBAVCODE return av_opt_set_defaults2(s, mask, flags); } #endif - -#if FF_API_SET_STRING_OLD -const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc){ - const AVOption *o; - if (av_set_string3(obj, name, val, alloc, &o) < 0) - return NULL; - return o; -} - -const AVOption *av_set_string(void *obj, const char *name, const char *val){ - const AVOption *o; - if (av_set_string3(obj, name, val, 0, &o) < 0) - return NULL; - return o; -} -#endif diff --git a/libavcodec/opt.h b/libavcodec/opt.h deleted file mode 100644 index ece54aad24..0000000000 --- a/libavcodec/opt.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * AVOptions - * copyright (c) 2005 Michael Niedermayer - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_OPT_H -#define AVCODEC_OPT_H - -/** - * @file - * AVOptions - */ - -#include "libavutil/rational.h" -#include "avcodec.h" -#include "libavutil/opt.h" - -#if FF_API_SET_STRING_OLD -/** - * @see av_set_string2() - */ -attribute_deprecated const AVOption *av_set_string(void *obj, const char *name, const char *val); - -/** - * @return a pointer to the AVOption corresponding to the field set or - * NULL if no matching AVOption exists, or if the value val is not - * valid - * @see av_set_string3() - */ -attribute_deprecated const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc); -#endif - -#endif /* AVCODEC_OPT_H */ diff --git a/libavcodec/version.h b/libavcodec/version.h index 5c81e3a671..679a38e7e5 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_SET_STRING_OLD -#define FF_API_SET_STRING_OLD (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_INOFFICIAL #define FF_API_INOFFICIAL (LIBAVCODEC_VERSION_MAJOR < 53) #endif diff --git a/libswscale/options.c b/libswscale/options.c index 59b99943db..7cee46076f 100644 --- a/libswscale/options.c +++ b/libswscale/options.c @@ -20,7 +20,7 @@ #include "libavutil/avutil.h" #include "libavutil/pixfmt.h" -#include "libavcodec/opt.h" +#include "libavutil/opt.h" #include "swscale.h" #include "swscale_internal.h" From 251cf997cff7f3869bca043d20ba771e0588cae3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 3 Feb 2011 15:00:50 +0100 Subject: [PATCH 044/172] lavc: remove the FF_API_INOFFICIAL cruft. --- libavcodec/avcodec.h | 3 --- libavcodec/options.c | 3 --- libavcodec/version.h | 3 --- 3 files changed, 9 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 3eac5672b1..f90aa81ab7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1464,9 +1464,6 @@ typedef struct AVCodecContext { #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. #define FF_COMPLIANCE_NORMAL 0 -#if FF_API_INOFFICIAL -#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead). -#endif #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. diff --git a/libavcodec/options.c b/libavcodec/options.c index 2f9d7d93c7..3b92497770 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -164,9 +164,6 @@ static const AVOption options[]={ {"very", "strictly conform to a older more strict version of the spec or reference software", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_VERY_STRICT, INT_MIN, INT_MAX, V|D|E, "strict"}, {"strict", "strictly conform to all the things in the spec no matter what consequences", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_STRICT, INT_MIN, INT_MAX, V|D|E, "strict"}, {"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|D|E, "strict"}, -#if FF_API_INOFFICIAL -{"inofficial", "allow unofficial extensions (deprecated - use unofficial)", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_UNOFFICIAL, INT_MIN, INT_MAX, V|D|E, "strict"}, -#endif {"unofficial", "allow unofficial extensions", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_UNOFFICIAL, INT_MIN, INT_MAX, V|D|E, "strict"}, {"experimental", "allow non standardized experimental things", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|D|E, "strict"}, {"b_qoffset", "qp offset between P and B frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, -FLT_MAX, FLT_MAX, V|E}, diff --git a/libavcodec/version.h b/libavcodec/version.h index 679a38e7e5..3146f765ee 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -41,9 +41,6 @@ #ifndef FF_API_PALETTE_CONTROL #define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_INOFFICIAL -#define FF_API_INOFFICIAL (LIBAVCODEC_VERSION_MAJOR < 53) -#endif #ifndef FF_API_OLD_SAMPLE_FMT #define FF_API_OLD_SAMPLE_FMT (LIBAVCODEC_VERSION_MAJOR < 54) #endif From 3453a231a6cebe5989c213be0f9fd6c71ec5ea23 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Apr 2011 20:46:49 +0200 Subject: [PATCH 045/172] lavc: remove misc disabled cruft. --- libavcodec/Makefile | 1 - libavcodec/avcodec.h | 114 +--------------------------------------- libavcodec/dsputil.h | 8 --- libavcodec/imgconvert.c | 51 ------------------ libavcodec/opt.c | 66 ----------------------- libavcodec/options.c | 3 -- libavcodec/parser.c | 37 ------------- libavcodec/utils.c | 48 +---------------- libavcodec/xvmc.h | 21 -------- 9 files changed, 4 insertions(+), 345 deletions(-) delete mode 100644 libavcodec/opt.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1cdae2c669..784226f7af 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -15,7 +15,6 @@ OBJS = allcodecs.o \ fmtconvert.o \ imgconvert.o \ jrevdct.o \ - opt.o \ options.o \ parser.o \ raw.o \ diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index f90aa81ab7..40d3b2245b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -33,12 +33,6 @@ #include "libavcodec/version.h" -#if LIBAVCODEC_VERSION_MAJOR < 53 -# define FF_INTERNALC_MEM_TYPE unsigned int -#else -# define FF_INTERNALC_MEM_TYPE size_t -#endif - /** * Identify the syntax and semantics of the bitstream. * The principle is roughly: @@ -117,9 +111,6 @@ enum CodecID { CODEC_ID_QDRAW, CODEC_ID_VIXL, CODEC_ID_QPEG, -#if LIBAVCODEC_VERSION_MAJOR < 53 - CODEC_ID_XVID, -#endif CODEC_ID_PNG, CODEC_ID_PPM, CODEC_ID_PBM, @@ -364,18 +355,6 @@ enum CodecID { CODEC_ID_FFMETADATA=0x21000, ///< Dummy codec for streams containing only metadata information. }; -#if LIBAVCODEC_VERSION_MAJOR < 53 -#define CodecType AVMediaType - -#define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN -#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO -#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO -#define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA -#define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE -#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT -#define CODEC_TYPE_NB AVMEDIA_TYPE_NB -#endif - #if FF_API_OLD_SAMPLE_FMT #define SampleFormat AVSampleFormat @@ -1100,9 +1079,6 @@ typedef struct AVPacket { int64_t convergence_duration; } AVPacket; #define AV_PKT_FLAG_KEY 0x0001 -#if LIBAVCODEC_VERSION_MAJOR < 53 -#define PKT_FLAG_KEY AV_PKT_FLAG_KEY -#endif /** * Audio Video Frame. @@ -1277,9 +1253,6 @@ typedef struct AVCodecContext { */ int frame_size; int frame_number; ///< audio or video frame number -#if LIBAVCODEC_VERSION_MAJOR < 53 - int real_pict_num; ///< Returns the real picture number of previous encoded frame. -#endif /** * Number of frames the decoded output will be delayed relative to @@ -3343,23 +3316,6 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int * const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); void avcodec_set_dimensions(AVCodecContext *s, int width, int height); -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * Return the pixel format corresponding to the name name. - * - * If there is no pixel format with name name, then look for a - * pixel format with the name corresponding to the native endian - * format of name. - * For example in a little-endian system, first look for "gray16", - * then for "gray16le". - * - * Finally if no pixel format has been found, return PIX_FMT_NONE. - * - * @deprecated Deprecated in favor of av_get_pix_fmt(). - */ -attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name); -#endif - /** * Return a value representing the fourCC code associated to the * pixel format pix_fmt, or 0 if no associated fourCC code can be @@ -3428,14 +3384,6 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Use av_get_pix_fmt_string() instead. - */ -attribute_deprecated -void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt); -#endif - #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ @@ -3483,13 +3431,6 @@ const char *avcodec_license(void); */ void avcodec_init(void); -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Deprecated in favor of avcodec_register(). - */ -attribute_deprecated void register_avcodec(AVCodec *codec); -#endif - /** * Register the codec codec and initialize libavcodec. * @@ -3634,24 +3575,8 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]); -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Deprecated in favor of av_check_image_size(). - */ -attribute_deprecated -int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h); -#endif - enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Set s->thread_count before calling avcodec_open() instead of calling this. - */ -attribute_deprecated -int avcodec_thread_init(AVCodecContext *s, int thread_count); -void avcodec_thread_free(AVCodecContext *s); -#endif int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); //FIXME func typedef @@ -4036,15 +3961,6 @@ AVCodecParser *av_parser_next(AVCodecParser *c); void av_register_codec_parser(AVCodecParser *parser); AVCodecParserContext *av_parser_init(int codec_id); -#if LIBAVCODEC_VERSION_MAJOR < 53 -attribute_deprecated -int av_parser_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, - int64_t pts, int64_t dts); -#endif - /** * Parse a packet. * @@ -4123,7 +4039,7 @@ AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); * * @see av_realloc */ -void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size); +void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); /** * Allocate a buffer, reusing the given one if large enough. @@ -4137,17 +4053,7 @@ void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_s * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and * *size 0 if an error occurred. */ -void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size); - -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Deprecated in favor of av_image_copy(). - */ -attribute_deprecated -void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4], - uint8_t *src_data[4], int src_linesize[4], - enum PixelFormat pix_fmt, int width, int height); -#endif +void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); /** * Copy image src to dst. Wraps av_picture_data_copy() above. @@ -4176,22 +4082,6 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, */ unsigned int av_xiphlacing(unsigned char *s, unsigned int v); -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * Parse str and put in width_ptr and height_ptr the detected values. - * - * @deprecated Deprecated in favor of av_parse_video_size(). - */ -attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str); - -/** - * Parse str and store the detected values in *frame_rate. - * - * @deprecated Deprecated in favor of av_parse_video_rate(). - */ -attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str); -#endif - /** * Logs a generic warning message about a missing feature. This function is * intended to be used internally by Libav (libavcodec, libavformat, etc.) diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 99b32831ec..8d8bc29dd5 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -104,14 +104,6 @@ void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block); void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block); /* 1/2^n downscaling functions from imgconvert.c */ -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * @deprecated Use av_image_copy_plane() instead. - */ -attribute_deprecated -void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); -#endif - void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 09ccdbc906..23e4318c71 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -425,40 +425,11 @@ const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt) return av_pix_fmt_descriptors[pix_fmt].name; } -#if LIBAVCODEC_VERSION_MAJOR < 53 -enum PixelFormat avcodec_get_pix_fmt(const char *name) -{ - return av_get_pix_fmt(name); -} - -void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt) -{ - av_get_pix_fmt_string(buf, buf_size, pix_fmt); -} -#endif - int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt) { return av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL; } -#if LIBAVCODEC_VERSION_MAJOR < 53 -int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt){ - return ff_set_systematic_pal2(pal, pix_fmt); -} - -int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width) -{ - return av_image_fill_linesizes(picture->linesize, pix_fmt, width); -} - -int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, - int height) -{ - return av_image_fill_pointers(picture->data, pix_fmt, height, ptr, picture->linesize); -} -#endif - int avpicture_fill(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, int width, int height) { @@ -693,28 +664,6 @@ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelForma return dst_pix_fmt; } -#if LIBAVCODEC_VERSION_MAJOR < 53 -void ff_img_copy_plane(uint8_t *dst, int dst_wrap, - const uint8_t *src, int src_wrap, - int width, int height) -{ - av_image_copy_plane(dst, dst_wrap, src, src_wrap, width, height); -} - -int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane) -{ - return av_image_get_linesize(pix_fmt, width, plane); -} - -void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4], - uint8_t *src_data[4], int src_linesize[4], - enum PixelFormat pix_fmt, int width, int height) -{ - av_image_copy(dst_data, dst_linesize, src_data, src_linesize, - pix_fmt, width, height); -} -#endif - void av_picture_copy(AVPicture *dst, const AVPicture *src, enum PixelFormat pix_fmt, int width, int height) { diff --git a/libavcodec/opt.c b/libavcodec/opt.c deleted file mode 100644 index f2bff96380..0000000000 --- a/libavcodec/opt.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * AVOptions ABI compatibility wrapper - * Copyright (c) 2010 Michael Niedermayer - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "avcodec.h" -#include "opt.h" - -#if LIBAVCODEC_VERSION_MAJOR < 53 && CONFIG_SHARED && HAVE_SYMVER - -FF_SYMVER(const AVOption *, av_find_opt, (void *obj, const char *name, const char *unit, int mask, int flags), "LIBAVCODEC_52"){ - return av_find_opt(obj, name, unit, mask, flags); -} -FF_SYMVER(int, av_set_string3, (void *obj, const char *name, const char *val, int alloc, const AVOption **o_out), "LIBAVCODEC_52"){ - return av_set_string3(obj, name, val, alloc, o_out); -} -FF_SYMVER(const AVOption *, av_set_double, (void *obj, const char *name, double n), "LIBAVCODEC_52"){ - return av_set_double(obj, name, n); -} -FF_SYMVER(const AVOption *, av_set_q, (void *obj, const char *name, AVRational n), "LIBAVCODEC_52"){ - return av_set_q(obj, name, n); -} -FF_SYMVER(const AVOption *, av_set_int, (void *obj, const char *name, int64_t n), "LIBAVCODEC_52"){ - return av_set_int(obj, name, n); -} -FF_SYMVER(double, av_get_double, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){ - return av_get_double(obj, name, o_out); -} -FF_SYMVER(AVRational, av_get_q, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){ - return av_get_q(obj, name, o_out); -} -FF_SYMVER(int64_t, av_get_int, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){ - return av_get_int(obj, name, o_out); -} -FF_SYMVER(const char *, av_get_string, (void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len), "LIBAVCODEC_52"){ - return av_get_string(obj, name, o_out, buf, buf_len); -} -FF_SYMVER(const AVOption *, av_next_option, (void *obj, const AVOption *last), "LIBAVCODEC_52"){ - return av_next_option(obj, last); -} -FF_SYMVER(int, av_opt_show2, (void *obj, void *av_log_obj, int req_flags, int rej_flags), "LIBAVCODEC_52"){ - return av_opt_show2(obj, av_log_obj, req_flags, rej_flags); -} -FF_SYMVER(void, av_opt_set_defaults, (void *s), "LIBAVCODEC_52"){ - return av_opt_set_defaults(s); -} -FF_SYMVER(void, av_opt_set_defaults2, (void *s, int mask, int flags), "LIBAVCODEC_52"){ - return av_opt_set_defaults2(s, mask, flags); -} -#endif diff --git a/libavcodec/options.c b/libavcodec/options.c index 3b92497770..9a9ed7bf34 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -113,9 +113,6 @@ static const AVOption options[]={ {"cutoff", "set cutoff bandwidth", OFFSET(cutoff), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|E}, {"frame_size", NULL, OFFSET(frame_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|E}, {"frame_number", NULL, OFFSET(frame_number), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX}, -#if LIBAVCODEC_VERSION_MAJOR < 53 -{"real_pict_num", NULL, OFFSET(real_pict_num), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX}, -#endif {"delay", NULL, OFFSET(delay), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX}, {"qcomp", "video quantizer scale compression (VBR)", OFFSET(qcompress), FF_OPT_TYPE_FLOAT, 0.5, -FLT_MAX, FLT_MAX, V|E}, {"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), FF_OPT_TYPE_FLOAT, 0.5, 0, FLT_MAX, V|E}, diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 3ba3e9c4c7..d5b85c3e4e 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -105,43 +105,6 @@ void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){ } } -#if LIBAVCODEC_VERSION_MAJOR < 53 -/** - * - * @param buf input - * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output) - * @param pts input presentation timestamp - * @param dts input decoding timestamp - * @param poutbuf will contain a pointer to the first byte of the output frame - * @param poutbuf_size will contain the length of the output frame - * @return the number of bytes of the input bitstream used - * - * Example: - * @code - * while(in_len){ - * len = av_parser_parse(myparser, AVCodecContext, &data, &size, - * in_data, in_len, - * pts, dts); - * in_data += len; - * in_len -= len; - * - * if(size) - * decode_frame(data, size); - * } - * @endcode - * - * @deprecated Use av_parser_parse2() instead. - */ -int av_parser_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, - int64_t pts, int64_t dts) -{ - return av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, AV_NOPTS_VALUE); -} -#endif - int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, diff --git a/libavcodec/utils.c b/libavcodec/utils.c index aa2e55693c..a46dda7e9c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -48,7 +48,7 @@ static int volatile entangled_thread_counter=0; static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op); static void *codec_mutex; -void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size) +void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) { if(min_size < *size) return ptr; @@ -64,7 +64,7 @@ void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_s return ptr; } -void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size) +void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size) { void **p = ptr; if (min_size < *size) @@ -94,13 +94,6 @@ void avcodec_register(AVCodec *codec) codec->next = NULL; } -#if LIBAVCODEC_VERSION_MAJOR < 53 -void register_avcodec(AVCodec *codec) -{ - avcodec_register(codec); -} -#endif - unsigned avcodec_get_edge_width(void) { return EDGE_WIDTH; @@ -220,12 +213,6 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ *width=FFALIGN(*width, align); } -#if LIBAVCODEC_VERSION_MAJOR < 53 -int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){ - return av_image_check_size(w, h, 0, av_log_ctx); -} -#endif - int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ int i; int w= s->width; @@ -1123,20 +1110,6 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v) return n; } -#if LIBAVCODEC_VERSION_MAJOR < 53 -#include "libavutil/parseutils.h" - -int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str) -{ - return av_parse_video_size(width_ptr, height_ptr, str); -} - -int av_parse_video_frame_rate(AVRational *frame_rate, const char *arg) -{ - return av_parse_video_rate(frame_rate, arg); -} -#endif - int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){ int i; for(i=0; ithread_count = thread_count; - return ff_thread_init(s); -} - -void avcodec_thread_free(AVCodecContext *s) -{ -#if HAVE_THREADS - ff_thread_free(s); -#endif -} - -#endif diff --git a/libavcodec/xvmc.h b/libavcodec/xvmc.h index 6e18a88a16..1239015fcd 100644 --- a/libavcodec/xvmc.h +++ b/libavcodec/xvmc.h @@ -25,11 +25,6 @@ #include "avcodec.h" -#if LIBAVCODEC_VERSION_MAJOR < 53 -#define AV_XVMC_STATE_DISPLAY_PENDING 1 /** the surface should be shown, the video driver manipulates this */ -#define AV_XVMC_STATE_PREDICTION 2 /** the surface is needed for prediction, the codec manipulates this */ -#define AV_XVMC_STATE_OSD_SOURCE 4 /** the surface is needed for subpicture rendering */ -#endif #define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct the number is 1337 speak for the letters IDCT MCo (motion compensation) */ @@ -151,22 +146,6 @@ struct xvmc_pix_fmt { of coded blocks it contains. */ int next_free_data_block_num; - -/** extensions may be placed here */ -#if LIBAVCODEC_VERSION_MAJOR < 53 -//@{ - /** State flags used to work around limitations in the MPlayer video system. - 0 - Surface is not used. - 1 - Surface is still held in application to be displayed or is - still visible. - 2 - Surface is still held in libavcodec buffer for prediction. - */ - int state; - - /** pointer to the surface where the subpicture is rendered */ - void* p_osd_target_surface_render; -//}@ -#endif }; #endif /* AVCODEC_XVMC_H */ From 516fb5e40cf9d591914096be26ba56fc59294669 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Apr 2011 20:57:07 +0200 Subject: [PATCH 046/172] lavu: remove FF_API_OLD_EVAL_NAMES cruft --- libavutil/avutil.h | 3 --- libavutil/eval.c | 32 -------------------------------- libavutil/eval.h | 33 --------------------------------- 3 files changed, 68 deletions(-) diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 6f2517c092..edae38eb69 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -57,9 +57,6 @@ * Those FF_API_* defines are not part of public API. * They may change, break or disappear at any time. */ -#ifndef FF_API_OLD_EVAL_NAMES -#define FF_API_OLD_EVAL_NAMES (LIBAVUTIL_VERSION_MAJOR < 51) -#endif /** * Return the LIBAVUTIL_VERSION_INT constant. diff --git a/libavutil/eval.c b/libavutil/eval.c index 7488a310a7..a6a59a39ef 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -530,38 +530,6 @@ int av_expr_parse_and_eval(double *d, const char *s, return isnan(*d) ? AVERROR(EINVAL) : 0; } -#if FF_API_OLD_EVAL_NAMES -int av_parse_expr(AVExpr **expr, const char *s, - const char * const *const_names, - const char * const *func1_names, double (* const *funcs1)(void *, double), - const char * const *func2_names, double (* const *funcs2)(void *, double, double), - int log_offset, void *log_ctx) -{ - return av_expr_parse(expr, s, const_names, func1_names, funcs1, func2_names, funcs2, - log_offset, log_ctx); -} - -double av_eval_expr(AVExpr *e, const double *const_values, void *opaque) -{ - return av_expr_eval(e, const_values, opaque); -} - -int av_parse_and_eval_expr(double *res, const char *s, - const char * const *const_names, const double *const_values, - const char * const *func1_names, double (* const *funcs1)(void *, double), - const char * const *func2_names, double (* const *funcs2)(void *, double, double), - void *opaque, int log_offset, void *log_ctx) -{ - return av_expr_parse_and_eval(res, s, const_names, const_values, func1_names, funcs1, func2_names, funcs2, - opaque, log_offset, log_ctx); -} - -void av_free_expr(AVExpr *e) -{ - av_expr_free(e); -} -#endif /* FF_API_OLD_EVAL_NAMES */ - #ifdef TEST #undef printf static double const_values[] = { diff --git a/libavutil/eval.h b/libavutil/eval.h index a20a006ac8..c485c69fb1 100644 --- a/libavutil/eval.h +++ b/libavutil/eval.h @@ -91,39 +91,6 @@ double av_expr_eval(AVExpr *e, const double *const_values, void *opaque); */ void av_expr_free(AVExpr *e); -#if FF_API_OLD_EVAL_NAMES -/** - * @deprecated Deprecated in favor of av_expr_parse_and_eval(). - */ -attribute_deprecated -int av_parse_and_eval_expr(double *res, const char *s, - const char * const *const_names, const double *const_values, - const char * const *func1_names, double (* const *funcs1)(void *, double), - const char * const *func2_names, double (* const *funcs2)(void *, double, double), - void *opaque, int log_offset, void *log_ctx); - -/** - * @deprecated Deprecated in favor of av_expr_parse(). - */ -attribute_deprecated -int av_parse_expr(AVExpr **expr, const char *s, - const char * const *const_names, - const char * const *func1_names, double (* const *funcs1)(void *, double), - const char * const *func2_names, double (* const *funcs2)(void *, double, double), - int log_offset, void *log_ctx); -/** - * @deprecated Deprecated in favor of av_expr_eval(). - */ -attribute_deprecated -double av_eval_expr(AVExpr *e, const double *const_values, void *opaque); - -/** - * @deprecated Deprecated in favor of av_expr_free(). - */ -attribute_deprecated -void av_free_expr(AVExpr *e); -#endif /* FF_API_OLD_EVAL_NAMES */ - /** * Parse the string in numstr and return its value as a double. If * the string is empty, contains only whitespaces, or does not contain From 9e5c62c97fc0a6ee5764ec69cc6c237b5f70026b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Apr 2011 21:11:15 +0200 Subject: [PATCH 047/172] lavu: remove FF_API_OLD_IMAGE_NAMES cruft --- libavutil/avutil.h | 8 -------- libavutil/imgutils.c | 29 ----------------------------- libavutil/imgutils.h | 19 ------------------- 3 files changed, 56 deletions(-) diff --git a/libavutil/avutil.h b/libavutil/avutil.h index edae38eb69..abbdd0642a 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -94,14 +94,6 @@ enum AVMediaType { #define AV_TIME_BASE 1000000 #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} -/** - * Those FF_API_* defines are not part of public API. - * They may change, break or disappear at any time. - */ -#ifndef FF_API_OLD_IMAGE_NAMES -#define FF_API_OLD_IMAGE_NAMES (LIBAVUTIL_VERSION_MAJOR < 51) -#endif - #include "common.h" #include "error.h" #include "mathematics.h" diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 129fb9555d..544007f120 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -266,32 +266,3 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], } } } - -#if FF_API_OLD_IMAGE_NAMES -void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], - const AVPixFmtDescriptor *pixdesc) -{ - av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, pixdesc); -} - -int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane) -{ - return av_image_get_linesize(pix_fmt, width, plane); -} - -int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width) -{ - return av_image_fill_linesizes(linesizes, pix_fmt, width); -} - -int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, - uint8_t *ptr, const int linesizes[4]) -{ - return av_image_fill_pointers(data, pix_fmt, height, ptr, linesizes); -} - -int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) -{ - return av_image_check_size(w, h, log_offset, log_ctx); -} -#endif diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 6ebb1b0a6c..7abeb657fb 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -127,23 +127,4 @@ int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *lo int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt); -#if FF_API_OLD_IMAGE_NAMES -attribute_deprecated -void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], - const AVPixFmtDescriptor *pixdesc); - -attribute_deprecated -int av_get_image_linesize(enum PixelFormat pix_fmt, int width, int plane); - -attribute_deprecated -int av_fill_image_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width); - -attribute_deprecated -int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, - uint8_t *ptr, const int linesizes[4]); - -attribute_deprecated -int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); -#endif - #endif /* AVUTIL_IMGUTILS_H */ From 490a022d86ef1c506a79744c5a95368af356fc69 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Apr 2011 21:17:26 +0200 Subject: [PATCH 048/172] lavu: remove misc disabled cruft --- libavutil/error.h | 13 ------------- libavutil/file.c | 3 +-- libavutil/log.c | 5 +---- libavutil/mem.c | 6 +++--- libavutil/mem.h | 14 +++----------- 5 files changed, 8 insertions(+), 33 deletions(-) diff --git a/libavutil/error.h b/libavutil/error.h index 8c83ecde77..33332b18c4 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -37,25 +37,12 @@ #define AVUNERROR(e) (e) #endif -#if LIBAVUTIL_VERSION_MAJOR < 51 -#define AVERROR_INVALIDDATA AVERROR(EINVAL) ///< Invalid data found when processing input -#define AVERROR_IO AVERROR(EIO) ///< I/O error -#define AVERROR_NOENT AVERROR(ENOENT) ///< No such file or directory -#define AVERROR_NOFMT AVERROR(EILSEQ) ///< Unknown format -#define AVERROR_NOMEM AVERROR(ENOMEM) ///< Not enough memory -#define AVERROR_NOTSUPP AVERROR(ENOSYS) ///< Operation not supported -#define AVERROR_NUMEXPECTED AVERROR(EDOM) ///< Number syntax expected in filename -#define AVERROR_UNKNOWN AVERROR(EINVAL) ///< Unknown error -#endif - #define AVERROR_EOF AVERROR(EPIPE) ///< End of file #define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in Libav, patches welcome -#if LIBAVUTIL_VERSION_MAJOR > 50 #define AVERROR_INVALIDDATA (-MKTAG('I','N','D','A')) ///< Invalid data found when processing input #define AVERROR_NUMEXPECTED (-MKTAG('N','U','E','X')) ///< Number syntax expected in filename -#endif #define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found #define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found diff --git a/libavutil/file.c b/libavutil/file.c index 757e73bafb..3dcce7c2f8 100644 --- a/libavutil/file.c +++ b/libavutil/file.c @@ -47,7 +47,6 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, av_unused void *ptr; off_t off_size; char errbuf[128]; - size_t max_size = HAVE_MMAP ? SIZE_MAX : FF_INTERNAL_MEM_TYPE_MAX_VALUE; *bufptr = NULL; if (fd < 0) { @@ -66,7 +65,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, } off_size = st.st_size; - if (off_size > max_size) { + if (off_size > SIZE_MAX) { av_log(&file_log_ctx, AV_LOG_ERROR, "File size for file '%s' is too big\n", filename); close(fd); diff --git a/libavutil/log.c b/libavutil/log.c index 3b8244889f..72d2b914bd 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -29,10 +29,7 @@ #include "avutil.h" #include "log.h" -#if LIBAVUTIL_VERSION_MAJOR > 50 -static -#endif -int av_log_level = AV_LOG_INFO; +static int av_log_level = AV_LOG_INFO; static int flags; #if defined(_WIN32) && !defined(__MINGW32CE__) diff --git a/libavutil/mem.c b/libavutil/mem.c index 7a54bd0f7e..2aef9b0a1b 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -61,7 +61,7 @@ void free(void *ptr); memory allocator. You do not need to suppress this file because the linker will do it automatically. */ -void *av_malloc(FF_INTERNAL_MEM_TYPE size) +void *av_malloc(size_t size) { void *ptr = NULL; #if CONFIG_MEMALIGN_HACK @@ -116,7 +116,7 @@ void *av_malloc(FF_INTERNAL_MEM_TYPE size) return ptr; } -void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size) +void *av_realloc(void *ptr, size_t size) { #if CONFIG_MEMALIGN_HACK int diff; @@ -153,7 +153,7 @@ void av_freep(void *arg) *ptr = NULL; } -void *av_mallocz(FF_INTERNAL_MEM_TYPE size) +void *av_mallocz(size_t size) { void *ptr = av_malloc(size); if (ptr) diff --git a/libavutil/mem.h b/libavutil/mem.h index f52777b071..5dea492021 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -62,14 +62,6 @@ #define av_alloc_size(n) #endif -#if LIBAVUTIL_VERSION_MAJOR < 51 -# define FF_INTERNAL_MEM_TYPE unsigned int -# define FF_INTERNAL_MEM_TYPE_MAX_VALUE UINT_MAX -#else -# define FF_INTERNAL_MEM_TYPE size_t -# define FF_INTERNAL_MEM_TYPE_MAX_VALUE SIZE_MAX -#endif - /** * Allocate a block of size bytes with alignment suitable for all * memory accesses (including vectors if available on the CPU). @@ -78,7 +70,7 @@ * be allocated. * @see av_mallocz() */ -void *av_malloc(FF_INTERNAL_MEM_TYPE size) av_malloc_attrib av_alloc_size(1); +void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); /** * Allocate or reallocate a block of memory. @@ -92,7 +84,7 @@ void *av_malloc(FF_INTERNAL_MEM_TYPE size) av_malloc_attrib av_alloc_size(1); * cannot be reallocated or the function is used to free the memory block. * @see av_fast_realloc() */ -void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size) av_alloc_size(2); +void *av_realloc(void *ptr, size_t size) av_alloc_size(2); /** * Free a memory block which has been allocated with av_malloc(z)() or @@ -112,7 +104,7 @@ void av_free(void *ptr); * @return Pointer to the allocated block, NULL if it cannot be allocated. * @see av_malloc() */ -void *av_mallocz(FF_INTERNAL_MEM_TYPE size) av_malloc_attrib av_alloc_size(1); +void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); /** * Duplicate the string s. From 59d96941f0285a501989d5f2c9b69be0a1393ed5 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 15 Apr 2011 16:42:09 +0200 Subject: [PATCH 049/172] avio: remove AVIO_* access symbols in favor of new AVIO_FLAG_* symbols Make AVIO_FLAG_ access constants work as flags, and in particular fix the behavior of functions (such as avio_check()) which expect them to be flags rather than modes. This breaks API. --- ffmpeg.c | 2 +- ffserver.c | 4 ++-- libavformat/applehttp.c | 4 ++-- libavformat/applehttpproto.c | 6 +++--- libavformat/avio.c | 10 +++++----- libavformat/avio.h | 8 ++++---- libavformat/aviobuf.c | 12 ++++++------ libavformat/file.c | 11 +++++------ libavformat/gopher.c | 2 +- libavformat/http.c | 6 +++--- libavformat/img2.c | 4 ++-- libavformat/librtmp.c | 2 +- libavformat/matroskadec.c | 2 +- libavformat/md5proto.c | 4 ++-- libavformat/mmsh.c | 4 ++-- libavformat/mmst.c | 2 +- libavformat/mov.c | 2 +- libavformat/output-example.c | 2 +- libavformat/rtmpproto.c | 6 +++--- libavformat/rtpproto.c | 2 +- libavformat/rtsp.c | 16 ++++++++-------- libavformat/sapdec.c | 2 +- libavformat/sapenc.c | 4 ++-- libavformat/udp.c | 12 ++++++------ libavformat/utils.c | 2 +- 25 files changed, 65 insertions(+), 66 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index f5244d98fd..5b6e3eae67 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3750,7 +3750,7 @@ static void opt_output_file(const char *filename) } /* open the file */ - if ((err = avio_open(&oc->pb, filename, AVIO_WRONLY)) < 0) { + if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) { print_error(filename, err); ffmpeg_exit(1); } diff --git a/ffserver.c b/ffserver.c index ec8b773c26..5defd40847 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3422,7 +3422,7 @@ static int rtp_new_av_stream(HTTPContext *c, "rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port)); } - if (url_open(&h, ctx->filename, AVIO_WRONLY) < 0) + if (url_open(&h, ctx->filename, AVIO_FLAG_WRITE) < 0) goto fail; c->rtp_handles[stream_index] = h; max_packet_size = url_get_max_packet_size(h); @@ -3762,7 +3762,7 @@ static void build_feed_streams(void) } /* only write the header of the ffm file */ - if (avio_open(&s->pb, feed->feed_filename, AVIO_WRONLY) < 0) { + if (avio_open(&s->pb, feed->feed_filename, AVIO_FLAG_WRITE) < 0) { http_log("Could not open output feed file '%s'\n", feed->feed_filename); exit(1); diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 35759be3cb..df4494a785 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -170,7 +170,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url, if (!in) { close_in = 1; - if ((ret = avio_open(&in, url, AVIO_RDONLY)) < 0) + if ((ret = avio_open(&in, url, AVIO_FLAG_READ)) < 0) return ret; } @@ -293,7 +293,7 @@ reload: ret = ffurl_open(&v->input, v->segments[v->cur_seq_no - v->start_seq_no]->url, - AVIO_RDONLY); + AVIO_FLAG_READ); if (ret < 0) return ret; } diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c index 8842bd4dcf..8a9bcb1ade 100644 --- a/libavformat/applehttpproto.c +++ b/libavformat/applehttpproto.c @@ -115,7 +115,7 @@ static int parse_playlist(URLContext *h, const char *url) char line[1024]; const char *ptr; - if ((ret = avio_open(&in, url, AVIO_RDONLY)) < 0) + if ((ret = avio_open(&in, url, AVIO_FLAG_READ)) < 0) return ret; read_chomp_line(in, line, sizeof(line)); @@ -180,7 +180,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags) int ret, i; const char *nested_url; - if (flags & (AVIO_WRONLY | AVIO_RDWR)) + if (flags & AVIO_FLAG_WRITE) return AVERROR(ENOSYS); s = av_mallocz(sizeof(AppleHTTPContext)); @@ -275,7 +275,7 @@ retry: } url = s->segments[s->cur_seq_no - s->start_seq_no]->url, av_log(NULL, AV_LOG_DEBUG, "opening %s\n", url); - ret = ffurl_open(&s->seg_hd, url, AVIO_RDONLY); + ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ); if (ret < 0) { if (url_interrupt_cb()) return AVERROR_EXIT; diff --git a/libavformat/avio.c b/libavformat/avio.c index 4f8acb01ff..074d3eeb86 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -129,7 +129,7 @@ int ffurl_connect(URLContext* uc) return err; uc->is_connected = 1; //We must be careful here as ffurl_seek() could be slow, for example for http - if( (uc->flags & (AVIO_WRONLY | AVIO_RDWR)) + if( (uc->flags & AVIO_FLAG_WRITE) || !strcmp(uc->prot->name, "file")) if(!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0) uc->is_streamed= 1; @@ -289,21 +289,21 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int int ffurl_read(URLContext *h, unsigned char *buf, int size) { - if (h->flags & AVIO_WRONLY) + if (h->flags & AVIO_FLAG_WRITE) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read); } int ffurl_read_complete(URLContext *h, unsigned char *buf, int size) { - if (h->flags & AVIO_WRONLY) + if (h->flags & AVIO_FLAG_WRITE) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read); } int ffurl_write(URLContext *h, const unsigned char *buf, int size) { - if (!(h->flags & (AVIO_WRONLY | AVIO_RDWR))) + if (!(h->flags & AVIO_FLAG_WRITE)) return AVERROR(EIO); /* avoid sending too big packets */ if (h->max_packet_size && size > h->max_packet_size) @@ -342,7 +342,7 @@ int ffurl_close(URLContext *h) int url_exist(const char *filename) { URLContext *h; - if (ffurl_open(&h, filename, AVIO_RDONLY) < 0) + if (ffurl_open(&h, filename, AVIO_FLAG_READ) < 0) return 0; ffurl_close(h); return 1; diff --git a/libavformat/avio.h b/libavformat/avio.h index c63b545d33..a4ab5ae28c 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -347,7 +347,7 @@ attribute_deprecated int url_exist(const char *url); #endif // FF_API_OLD_AVIO /** - * Return AVIO_* access flags corresponding to the access permissions + * Return AVIO_FLAG_* access flags corresponding to the access permissions * of the resource in url, or a negative value corresponding to an * AVERROR code in case of failure. The returned access flags are * masked by the value in flags. @@ -527,9 +527,9 @@ int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); * constants, optionally ORed with other flags. * @{ */ -#define AVIO_RDONLY 1 /**< read-only */ -#define AVIO_WRONLY 2 /**< write-only */ -#define AVIO_RDWR 4 /**< read-write */ +#define AVIO_FLAG_READ 1 /**< read-only */ +#define AVIO_FLAG_WRITE 2 /**< write-only */ +#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */ /** * @} */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 2bacedbaa7..2b14d48ff5 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -53,7 +53,7 @@ int ffio_init_context(AVIOContext *s, s->buffer_size = buffer_size; s->buf_ptr = buffer; s->opaque = opaque; - url_resetbuf(s, write_flag ? AVIO_WRONLY : AVIO_RDONLY); + url_resetbuf(s, write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ); s->write_packet = write_packet; s->read_packet = read_packet; s->seek = seek; @@ -843,7 +843,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) } if (ffio_init_context(*s, buffer, buffer_size, - (h->flags & AVIO_WRONLY || h->flags & AVIO_RDWR), h, + h->flags & AVIO_FLAG_WRITE, h, ffurl_read, ffurl_write, ffurl_seek) < 0) { av_free(buffer); av_freep(s); @@ -872,15 +872,15 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size) s->buffer = buffer; s->buffer_size = buf_size; s->buf_ptr = buffer; - url_resetbuf(s, s->write_flag ? AVIO_WRONLY : AVIO_RDONLY); + url_resetbuf(s, s->write_flag ? AVIO_FLAG_WRITE : AVIO_FLAG_READ); return 0; } static int url_resetbuf(AVIOContext *s, int flags) { - assert(flags == AVIO_WRONLY || flags == AVIO_RDONLY); + assert(flags == AVIO_FLAG_WRITE || flags == AVIO_FLAG_READ); - if (flags & AVIO_WRONLY) { + if (flags & AVIO_FLAG_WRITE) { s->buf_end = s->buffer + s->buffer_size; s->write_flag = 1; } else { @@ -1038,7 +1038,7 @@ int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags) if(!*s) return AVERROR(ENOMEM); ret = ffio_init_context(*s, buf, buf_size, - (flags & AVIO_WRONLY || flags & AVIO_RDWR), + flags & AVIO_FLAG_WRITE, NULL, NULL, NULL, NULL); if(ret != 0) av_freep(s); diff --git a/libavformat/file.c b/libavformat/file.c index 1dcb2c8ac5..6a3ed5acb0 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -60,9 +60,9 @@ static int file_open(URLContext *h, const char *filename, int flags) av_strstart(filename, "file:", &filename); - if (flags & AVIO_RDWR) { + if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) { access = O_CREAT | O_TRUNC | O_RDWR; - } else if (flags & AVIO_WRONLY) { + } else if (flags & AVIO_FLAG_WRITE) { access = O_CREAT | O_TRUNC | O_WRONLY; } else { access = O_RDONLY; @@ -102,9 +102,8 @@ static int file_check(URLContext *h, int mask) if (ret < 0) return AVERROR(errno); - ret |= st.st_mode&S_IRUSR ? mask&AVIO_RDONLY : 0; - ret |= st.st_mode&S_IWUSR ? mask&AVIO_WRONLY : 0; - ret |= st.st_mode&S_IWUSR && st.st_mode&S_IRUSR ? mask&AVIO_RDWR : 0; + ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0; + ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0; return ret; } @@ -132,7 +131,7 @@ static int pipe_open(URLContext *h, const char *filename, int flags) fd = strtol(filename, &final, 10); if((filename == final) || *final ) {/* No digits found, or something like 10ab */ - if (flags & AVIO_WRONLY) { + if (flags & AVIO_FLAG_WRITE) { fd = 1; } else { fd = 0; diff --git a/libavformat/gopher.c b/libavformat/gopher.c index cfc07e79cf..1d38cd232f 100644 --- a/libavformat/gopher.c +++ b/libavformat/gopher.c @@ -100,7 +100,7 @@ static int gopher_open(URLContext *h, const char *uri, int flags) ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); s->hd = NULL; - err = ffurl_open(&s->hd, buf, AVIO_RDWR); + err = ffurl_open(&s->hd, buf, AVIO_FLAG_READ_WRITE); if (err < 0) goto fail; diff --git a/libavformat/http.c b/libavformat/http.c index bcfce80bff..190f844ea1 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -124,7 +124,7 @@ static int http_open_cnx(URLContext *h) port = 80; ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); - err = ffurl_open(&hd, buf, AVIO_RDWR); + err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE); if (err < 0) goto fail; @@ -296,7 +296,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr, /* send http header */ - post = h->flags & AVIO_WRONLY; + post = h->flags & AVIO_FLAG_WRITE; authstr = ff_http_auth_create_response(&s->auth_state, auth, path, post ? "POST" : "GET"); @@ -451,7 +451,7 @@ static int http_close(URLContext *h) HTTPContext *s = h->priv_data; /* signal end of chunked encoding if used */ - if ((h->flags & AVIO_WRONLY) && s->chunksize != -1) { + if ((h->flags & AVIO_FLAG_WRITE) && s->chunksize != -1) { ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); ret = ret > 0 ? 0 : ret; } diff --git a/libavformat/img2.c b/libavformat/img2.c index 2b5d63b0bd..84d841f0ed 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -278,7 +278,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) s->path, s->img_number)<0 && s->img_number > 1) return AVERROR(EIO); for(i=0; i<3; i++){ - if (avio_open(&f[i], filename, AVIO_RDONLY) < 0) { + if (avio_open(&f[i], filename, AVIO_FLAG_READ) < 0) { if(i==1) break; av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename); @@ -362,7 +362,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); } for(i=0; i<3; i++){ - if (avio_open(&pb[i], filename, AVIO_WRONLY) < 0) { + if (avio_open(&pb[i], filename, AVIO_FLAG_WRITE) < 0) { av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename); return AVERROR(EIO); } diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c index db5cc9858b..30fe8a196b 100644 --- a/libavformat/librtmp.c +++ b/libavformat/librtmp.c @@ -94,7 +94,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) goto fail; } - if (flags & AVIO_WRONLY) + if (flags & AVIO_FLAG_WRITE) RTMP_EnableWrite(r); if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) { diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 19c7ca6384..0fa94a16d5 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1331,7 +1331,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) && track->codec_priv.data != NULL) { int ret; ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size, - AVIO_RDONLY, NULL, NULL, NULL, NULL); + AVIO_FLAG_READ, NULL, NULL, NULL, NULL); ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size); if (ret < 0) return ret; diff --git a/libavformat/md5proto.c b/libavformat/md5proto.c index 8b811ec3d6..4630c49f5c 100644 --- a/libavformat/md5proto.c +++ b/libavformat/md5proto.c @@ -36,7 +36,7 @@ static int md5_open(URLContext *h, const char *filename, int flags) return -1; } - if (flags != AVIO_WRONLY) + if (!flags & AVIO_FLAG_WRITE) return AVERROR(EINVAL); av_md5_init(h->priv_data); @@ -65,7 +65,7 @@ static int md5_close(URLContext *h) av_strstart(filename, "md5:", &filename); if (*filename) { - err = ffurl_open(&out, filename, AVIO_WRONLY); + err = ffurl_open(&out, filename, AVIO_FLAG_WRITE); if (err) return err; err = ffurl_write(out, buf, i*2+1); diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c index 1b9b494f57..203691e2fc 100644 --- a/libavformat/mmsh.c +++ b/libavformat/mmsh.c @@ -233,7 +233,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags) port = 80; // default mmsh protocol port ff_url_join(httpname, sizeof(httpname), "http", NULL, host, port, path); - if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_RDONLY) < 0) { + if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ) < 0) { return AVERROR(EIO); } @@ -261,7 +261,7 @@ static int mmsh_open(URLContext *h, const char *uri, int flags) // close the socket and then reopen it for sending the second play request. ffurl_close(mms->mms_hd); memset(headers, 0, sizeof(headers)); - if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_RDONLY) < 0) { + if (ffurl_alloc(&mms->mms_hd, httpname, AVIO_FLAG_READ) < 0) { return AVERROR(EIO); } stream_selection = av_mallocz(mms->stream_num * 19 + 1); diff --git a/libavformat/mmst.c b/libavformat/mmst.c index a3f260939d..e1904de1e2 100644 --- a/libavformat/mmst.c +++ b/libavformat/mmst.c @@ -523,7 +523,7 @@ static int mms_open(URLContext *h, const char *uri, int flags) // establish tcp connection. ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, mmst->host, port, NULL); - err = ffurl_open(&mms->mms_hd, tcpname, AVIO_RDWR); + err = ffurl_open(&mms->mms_hd, tcpname, AVIO_FLAG_READ_WRITE); if (err) goto fail; diff --git a/libavformat/mov.c b/libavformat/mov.c index bd8cf031e0..76dc8a13af 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1721,7 +1721,7 @@ static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref) av_strlcat(filename, ref->path + l + 1, 1024); - if (!avio_open(pb, filename, AVIO_RDONLY)) + if (!avio_open(pb, filename, AVIO_FLAG_READ)) return 0; } } diff --git a/libavformat/output-example.c b/libavformat/output-example.c index 27db78c658..ddd16f1eed 100644 --- a/libavformat/output-example.c +++ b/libavformat/output-example.c @@ -492,7 +492,7 @@ int main(int argc, char **argv) /* open the output file, if needed */ if (!(fmt->flags & AVFMT_NOFILE)) { - if (avio_open(&oc->pb, filename, AVIO_WRONLY) < 0) { + if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) { fprintf(stderr, "Could not open '%s'\n", filename); exit(1); } diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 3413b62c8b..70e4b142d6 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -805,7 +805,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) if (!rt) return AVERROR(ENOMEM); s->priv_data = rt; - rt->is_input = !(flags & AVIO_WRONLY); + rt->is_input = !(flags & AVIO_FLAG_WRITE); av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, path, sizeof(path), s->filename); @@ -814,8 +814,8 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) port = RTMP_DEFAULT_PORT; ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); - if (ffurl_open(&rt->stream, buf, AVIO_RDWR) < 0) { - av_log(s, AV_LOG_ERROR, "Cannot open connection %s\n", buf); + if (ffurl_open(&rt->stream, buf, AVIO_FLAG_READ_WRITE) < 0) { + av_log(s , AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index b92b2e7ace..e1659ee02d 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -145,7 +145,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) char path[1024]; const char *p; - is_output = (flags & AVIO_WRONLY); + is_output = (flags & AVIO_FLAG_WRITE); s = av_mallocz(sizeof(RTPContext)); if (!s) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 62c9d3543e..58f7ddc1a6 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1116,14 +1116,14 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, "?localport=%d", j); /* we will use two ports per rtp stream (rtp and rtcp) */ j += 2; - if (ffurl_open(&rtsp_st->rtp_handle, buf, AVIO_RDWR) == 0) + if (ffurl_open(&rtsp_st->rtp_handle, buf, AVIO_FLAG_READ_WRITE) == 0) goto rtp_opened; } } #if 0 /* then try on any port */ - if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", AVIO_RDONLY) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, "rtp://", AVIO_FLAG_READ) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1269,7 +1269,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST); ff_url_join(url, sizeof(url), "rtp", NULL, namebuf, port, "?ttl=%d", ttl); - if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_RDWR) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1396,7 +1396,7 @@ redirect: av_get_random_seed(), av_get_random_seed()); /* GET requests */ - if (ffurl_alloc(&rt->rtsp_hd, httpname, AVIO_RDONLY) < 0) { + if (ffurl_alloc(&rt->rtsp_hd, httpname, AVIO_FLAG_READ) < 0) { err = AVERROR(EIO); goto fail; } @@ -1417,7 +1417,7 @@ redirect: } /* POST requests */ - if (ffurl_alloc(&rt->rtsp_hd_out, httpname, AVIO_WRONLY) < 0 ) { + if (ffurl_alloc(&rt->rtsp_hd_out, httpname, AVIO_FLAG_WRITE) < 0 ) { err = AVERROR(EIO); goto fail; } @@ -1460,7 +1460,7 @@ redirect: } else { /* open the tcp connection */ ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL); - if (ffurl_open(&rt->rtsp_hd, tcpname, AVIO_RDWR) < 0) { + if (ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE) < 0) { err = AVERROR(EIO); goto fail; } @@ -1807,7 +1807,7 @@ static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap) namebuf, rtsp_st->sdp_port, "?localport=%d&ttl=%d", rtsp_st->sdp_port, rtsp_st->sdp_ttl); - if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_RDWR) < 0) { + if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1863,7 +1863,7 @@ static int rtp_read_header(AVFormatContext *s, if (!ff_network_init()) return AVERROR(EIO); - ret = ffurl_open(&in, s->filename, AVIO_RDONLY); + ret = ffurl_open(&in, s->filename, AVIO_FLAG_READ); if (ret) goto fail; diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 1eb40b7ee5..88150fc772 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -85,7 +85,7 @@ static int sap_read_header(AVFormatContext *s, ff_url_join(url, sizeof(url), "udp", NULL, host, port, "?localport=%d", port); - ret = ffurl_open(&sap->ann_fd, url, AVIO_RDONLY); + ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_READ); if (ret) goto fail; diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 455e65341f..3abd79e4e8 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -146,7 +146,7 @@ static int sap_write_header(AVFormatContext *s) "?ttl=%d", ttl); if (!same_port) base_port += 2; - ret = ffurl_open(&fd, url, AVIO_WRONLY); + ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE); if (ret) { ret = AVERROR(EIO); goto fail; @@ -158,7 +158,7 @@ static int sap_write_header(AVFormatContext *s) ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port, "?ttl=%d&connect=1", ttl); - ret = ffurl_open(&sap->ann_fd, url, AVIO_WRONLY); + ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE); if (ret) { ret = AVERROR(EIO); goto fail; diff --git a/libavformat/udp.c b/libavformat/udp.c index e16dc4c7e0..76e3f1a4a2 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -315,7 +315,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) h->is_streamed = 1; h->max_packet_size = 1472; - is_output = (flags & AVIO_WRONLY); + is_output = (flags & AVIO_FLAG_WRITE); s = av_mallocz(sizeof(UDPContext)); if (!s) @@ -358,14 +358,14 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* XXX: fix av_url_split */ if (hostname[0] == '\0' || hostname[0] == '?') { /* only accepts null hostname if input */ - if (flags & AVIO_WRONLY) + if (flags & AVIO_FLAG_WRITE) goto fail; } else { if (ff_udp_set_remote_url(h, uri) < 0) goto fail; } - if (s->is_multicast && !(h->flags & AVIO_WRONLY)) + if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) s->local_port = port; udp_fd = udp_socket_create(s, &my_addr, &len); if (udp_fd < 0) @@ -382,7 +382,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* the bind is needed to give a port to the socket now */ /* if multicast, try the multicast address bind first */ - if (s->is_multicast && !(h->flags & AVIO_WRONLY)) { + if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) { bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len); } /* bind to the local address if not multicast or if the multicast @@ -395,7 +395,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) s->local_port = udp_port(&my_addr, len); if (s->is_multicast) { - if (h->flags & AVIO_WRONLY) { + if (h->flags & AVIO_FLAG_WRITE) { /* output */ if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0) goto fail; @@ -478,7 +478,7 @@ static int udp_close(URLContext *h) { UDPContext *s = h->priv_data; - if (s->is_multicast && !(h->flags & AVIO_WRONLY)) + if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr); closesocket(s->udp_fd); av_free(s); diff --git a/libavformat/utils.c b/libavformat/utils.c index 1e70b4f592..0c80ff618e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -561,7 +561,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, hack needed to handle RTSP/TCP */ if (!fmt || !(fmt->flags & AVFMT_NOFILE)) { /* if no file needed do not try to open one */ - if ((err=avio_open(&pb, filename, AVIO_RDONLY)) < 0) { + if ((err=avio_open(&pb, filename, AVIO_FLAG_READ)) < 0) { goto fail; } if (buf_size > 0) { From 55815edca038997ec283569a192a3eca7f2143bc Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Apr 2011 01:32:37 +0200 Subject: [PATCH 050/172] prefer avio_check() over url_exist() The problem with url_exist() is that it tries to open a resource in RDONLY mode. If the file is a FIFO and there is already a reading client, the open() call will hang. By using avio_check() with access mode of 0, the second reading process will check if the file exists without attempting to open it, thus avoiding the lock. Fix issue #1663. Signed-off-by: Anton Khirnov --- ffmpeg.c | 2 +- ffserver.c | 4 ++-- libavformat/img2.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 5b6e3eae67..6e620bf55e 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3733,7 +3733,7 @@ static void opt_output_file(const char *filename) (strchr(filename, ':') == NULL || filename[1] == ':' || av_strstart(filename, "file:", NULL))) { - if (url_exist(filename)) { + if (avio_check(filename, 0) == 0) { if (!using_stdin) { fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename); fflush(stderr); diff --git a/ffserver.c b/ffserver.c index 5defd40847..d341182a4f 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3679,7 +3679,7 @@ static void build_feed_streams(void) for(feed = first_feed; feed != NULL; feed = feed->next_feed) { int fd; - if (url_exist(feed->feed_filename)) { + if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) { /* See if it matches */ AVFormatContext *s; int matches = 0; @@ -3752,7 +3752,7 @@ static void build_feed_streams(void) unlink(feed->feed_filename); } } - if (!url_exist(feed->feed_filename)) { + if (avio_check(feed->feed_filename, AVIO_FLAG_WRITE) <= 0) { AVFormatContext s1 = {0}, *s = &s1; if (feed->readonly) { diff --git a/libavformat/img2.c b/libavformat/img2.c index 84d841f0ed..1d50fbf567 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -131,11 +131,11 @@ static int find_image_range(int *pfirst_index, int *plast_index, if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ *pfirst_index = *plast_index = 1; - if(url_exist(buf)) + if (avio_check(buf, AVIO_FLAG_READ) > 0) return 0; return -1; } - if (url_exist(buf)) + if (avio_check(buf, AVIO_FLAG_READ) > 0) break; } if (first_index == 5) @@ -153,7 +153,7 @@ static int find_image_range(int *pfirst_index, int *plast_index, if (av_get_frame_filename(buf, sizeof(buf), path, last_index + range1) < 0) goto fail; - if (!url_exist(buf)) + if (avio_check(buf, AVIO_FLAG_READ) <= 0) break; range = range1; /* just in case... */ From cda7aa9eba79e113c8e46455b81e3f5a047a8d98 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 19 Apr 2011 19:50:23 +0200 Subject: [PATCH 051/172] lavc: remove reference to opt.h from Makefile. Fixes make install after 3453a231a6cebe5989c213be0f9fd6c71ec5ea23. --- libavcodec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 784226f7af..f05244ed95 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak NAME = avcodec FFLIBS = avutil -HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h version.h xvmc.h +HEADERS = avcodec.h avfft.h dxva2.h vaapi.h vdpau.h version.h xvmc.h OBJS = allcodecs.o \ audioconvert.o \ From 31d76ec2883c04d29d1f173ea99e605a6936613a Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 17 Apr 2011 16:57:55 -0400 Subject: [PATCH 052/172] In avcodec_open(), set return code to an error value only when an error occurs instead of unconditionally at the start of the function. This fixes a bug where a successful call to ff_thread_init() masks errors that occur after that point in the function. It also makes future bugs like this less likely since the error code is now set near to the point in the code where the error is found. --- libavcodec/utils.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index a46dda7e9c..0190e6652c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -456,7 +456,7 @@ AVFrame *avcodec_alloc_frame(void){ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) { - int ret= -1; + int ret = 0; /* If there is a user-supplied mutex locking routine, call it. */ if (ff_lockmgr_cb) { @@ -467,11 +467,14 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) entangled_thread_counter++; if(entangled_thread_counter != 1){ av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); + ret = -1; goto end; } - if(avctx->codec || !codec) + if(avctx->codec || !codec) { + ret = AVERROR(EINVAL); goto end; + } if (codec->priv_data_size > 0) { if(!avctx->priv_data){ @@ -521,6 +524,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) { av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n"); + ret = AVERROR(EINVAL); goto free_and_end; } avctx->frame_number = 0; @@ -535,6 +539,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) if (avctx->codec->max_lowres < avctx->lowres) { av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n", avctx->codec->max_lowres); + ret = AVERROR(EINVAL); goto free_and_end; } if (avctx->codec->sample_fmts && avctx->codec->encode) { @@ -544,6 +549,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) break; if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n"); + ret = AVERROR(EINVAL); goto free_and_end; } } @@ -554,7 +560,6 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) goto free_and_end; } } - ret=0; end: entangled_thread_counter--; From 488d2b6349e3c07fec73c28a165f8d292b413362 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 19 Apr 2011 21:16:35 +0200 Subject: [PATCH 053/172] lavu: remove disabled sha1 cruft. --- libavutil/Makefile | 1 - libavutil/sha.c | 24 ------------------- libavutil/sha1.h | 57 ---------------------------------------------- 3 files changed, 82 deletions(-) delete mode 100644 libavutil/sha1.h diff --git a/libavutil/Makefile b/libavutil/Makefile index baee496e7c..8c3cc60dab 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -35,7 +35,6 @@ HEADERS = adler32.h \ rational.h \ samplefmt.h \ sha.h \ - sha1.h \ BUILT_HEADERS = avconfig.h diff --git a/libavutil/sha.c b/libavutil/sha.c index 6d9c84ecfa..ae6069dd34 100644 --- a/libavutil/sha.c +++ b/libavutil/sha.c @@ -25,7 +25,6 @@ #include "avutil.h" #include "bswap.h" #include "sha.h" -#include "sha1.h" #include "intreadwrite.h" /** hash context */ @@ -324,29 +323,6 @@ void av_sha_final(AVSHA* ctx, uint8_t *digest) AV_WB32(digest + i*4, ctx->state[i]); } -#if LIBAVUTIL_VERSION_MAJOR < 51 -struct AVSHA1 { - AVSHA sha; -}; - -const int av_sha1_size = sizeof(struct AVSHA1); - -void av_sha1_init(struct AVSHA1* context) -{ - av_sha_init(&context->sha, 160); -} - -void av_sha1_update(struct AVSHA1* context, const uint8_t* data, unsigned int len) -{ - av_sha_update(&context->sha, data, len); -} - -void av_sha1_final(struct AVSHA1* context, uint8_t digest[20]) -{ - av_sha_final(&context->sha, digest); -} -#endif - #ifdef TEST #include #undef printf diff --git a/libavutil/sha1.h b/libavutil/sha1.h deleted file mode 100644 index b60d7704c0..0000000000 --- a/libavutil/sha1.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2007 Michael Niedermayer - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_SHA1_H -#define AVUTIL_SHA1_H - -#include - -extern const int av_sha1_size; - -struct AVSHA1; - -/** - * Initialize SHA-1 hashing. - * - * @param context pointer to the function context (of size av_sha_size) - * @deprecated use av_sha_init() instead - */ -void av_sha1_init(struct AVSHA1* context); - -/** - * Update hash value. - * - * @param context hash function context - * @param data input data to update hash with - * @param len input data length - * @deprecated use av_sha_update() instead - */ -void av_sha1_update(struct AVSHA1* context, const uint8_t* data, unsigned int len); - -/** - * Finish hashing and output digest value. - * - * @param context hash function context - * @param digest buffer where output digest value is stored - * @deprecated use av_sha_final() instead - */ -void av_sha1_final(struct AVSHA1* context, uint8_t digest[20]); - -#endif /* AVUTIL_SHA1_H */ From 975c27340528b9e053a7ae9b63b764984e91941c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 19 Apr 2011 21:21:44 +0200 Subject: [PATCH 054/172] lavu: remove disabled ff_random_get_seed cruft. --- libavutil/random_seed.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 6dc8d22ca4..a1078d8bbb 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -80,11 +80,3 @@ uint32_t av_get_random_seed(void) return seed; return get_generic_seed(); } - -#if LIBAVUTIL_VERSION_MAJOR < 51 -attribute_deprecated uint32_t ff_random_get_seed(void); -uint32_t ff_random_get_seed(void) -{ - return av_get_random_seed(); -} -#endif From 7dfe244fbd9a3c0a24cac441a4ec777da8f3a666 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 19 Apr 2011 21:25:10 +0200 Subject: [PATCH 055/172] sws: remove disabled cruft. --- libswscale/rgb2rgb.c | 28 ---------------------------- libswscale/rgb2rgb.h | 10 ---------- libswscale/swscale.c | 8 -------- libswscale/swscale.h | 16 ---------------- libswscale/utils.c | 7 ------- 5 files changed, 69 deletions(-) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 12d6287a4b..74cc42e3b0 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -124,34 +124,6 @@ void sws_rgb2rgb_init(int flags) #endif /* HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX */ } -#if LIBSWSCALE_VERSION_MAJOR < 1 -void palette8topacked32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) -{ - sws_convertPalette8ToPacked32(src, dst, num_pixels, palette); -} - -void palette8topacked24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) -{ - sws_convertPalette8ToPacked24(src, dst, num_pixels, palette); -} - -/** - * Palette is assumed to contain BGR16, see rgb32to16 to convert the palette. - */ -void palette8torgb16(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) -{ - long i; - for (i=0; i Date: Tue, 19 Apr 2011 12:57:46 -0700 Subject: [PATCH 056/172] Prefer codec specific options over global ones, allowing codec to override global options. --- cmdutils.c | 79 +++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 7ff5986b51..64ed2b8051 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -79,12 +79,8 @@ void uninit_opts(void) av_freep(&sws_opts); #endif for (i = 0; i < opt_name_count; i++) { - //opt_values are only stored for codec-specific options in which case - //both the name and value are dup'd - if (opt_values[i]) { - av_freep(&opt_names[i]); - av_freep(&opt_values[i]); - } + av_freep(&opt_names[i]); + av_freep(&opt_values[i]); } av_freep(&opt_names); av_freep(&opt_values); @@ -235,6 +231,23 @@ int opt_default(const char *opt, const char *arg){ int ret= 0; const AVOption *o= NULL; int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0}; + AVCodec *p = NULL; + AVOutputFormat *oformat = NULL; + + while ((p = av_codec_next(p))) { + AVClass *c = p->priv_class; + if (c && av_find_opt(&c, opt, NULL, 0, 0)) + break; + } + if (p) + goto out; + while ((oformat = av_oformat_next(oformat))) { + const AVClass *c = oformat->priv_class; + if (c && av_find_opt(&c, opt, NULL, 0, 0)) + break; + } + if (oformat) + goto out; for(type=0; *avcodec_opts && type= 0; type++){ const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]); @@ -252,39 +265,25 @@ int opt_default(const char *opt, const char *arg){ ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o); else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE]) ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o); + if (ret >= 0) + opt += 1; } if (o && ret < 0) { fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt); exit(1); } if (!o) { - AVCodec *p = NULL; - AVOutputFormat *oformat = NULL; - while ((p=av_codec_next(p))){ - AVClass *c= p->priv_class; - if(c && av_find_opt(&c, opt, NULL, 0, 0)) - break; - } - if (!p) { - while ((oformat = av_oformat_next(oformat))) { - const AVClass *c = oformat->priv_class; - if (c && av_find_opt(&c, opt, NULL, 0, 0)) - break; - } - } - if(!p && !oformat){ - fprintf(stderr, "Unrecognized option '%s'\n", opt); - exit(1); - } + fprintf(stderr, "Unrecognized option '%s'\n", opt); + exit(1); } + out: // av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL)); - //FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1)); - opt_values[opt_name_count]= o ? NULL : av_strdup(arg); + opt_values[opt_name_count] = av_strdup(arg); opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1)); - opt_names[opt_name_count++]= o ? o->name : av_strdup(opt); + opt_names[opt_name_count++] = av_strdup(opt); if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug)) av_log_set_level(AV_LOG_DEBUG); @@ -358,16 +357,22 @@ void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec) for(i=0; iflags & flags) == flags)) - av_set_string3(ctx, opt_names[i], str, 1, NULL); - /* We need to use a differnt system to pass options to the private context because - it is not known which codec and thus context kind that will be when parsing options - we thus use opt_values directly instead of opts_ctx */ - if(!str && priv_ctx) { - if (av_find_opt(priv_ctx, opt_names[i], NULL, flags, flags)) - av_set_string3(priv_ctx, opt_names[i], opt_values[i], 0, NULL); + const char *str; + if (priv_ctx) { + if (av_find_opt(priv_ctx, opt_names[i], NULL, flags, flags)) { + if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 0, NULL) < 0) { + fprintf(stderr, "Invalid value '%s' for option '%s'\n", + opt_names[i], opt_values[i]); + exit(1); + } + } else + goto global; + } else { + global: + str = av_get_string(opts_ctx, opt_names[i], &opt, buf, sizeof(buf)); + /* if an option with name opt_names[i] is present in opts_ctx then str is non-NULL */ + if (str && ((opt->flags & flags) == flags)) + av_set_string3(ctx, opt_names[i], str, 1, NULL); } } } From 46f83e5b3c17a46fa9c86421e7b511cd00cb5d60 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Sat, 29 Jan 2011 17:05:42 -0800 Subject: [PATCH 057/172] In libx264 wrapper, do not set pic quality if no frame is output, avoids uninitialized reads. --- libavcodec/libx264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index db57eead78..5b20d35464 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -144,7 +144,8 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf, } x4->out_pic.key_frame = pic_out.b_keyframe; - x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; + if (bufsize) + x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; return bufsize; } From 51c1e255e53bc51b4b3bf071bdaf3e92c4814acc Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Tue, 19 Apr 2011 23:03:51 +0200 Subject: [PATCH 058/172] oggparsecelt: call av_set_pts_info unconditionally. Signed-off-by: Nicolas George --- libavformat/oggparsecelt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c index b3c8660c9d..488fa28bed 100644 --- a/libavformat/oggparsecelt.c +++ b/libavformat/oggparsecelt.c @@ -71,8 +71,7 @@ static int celt_header(AVFormatContext *s, int idx) st->codec->sample_fmt = AV_SAMPLE_FMT_S16; st->codec->extradata = extradata; st->codec->extradata_size = 2 * sizeof(uint32_t); - if (sample_rate) - av_set_pts_info(st, 64, 1, sample_rate); + av_set_pts_info(st, 64, 1, sample_rate); priv->extra_headers_left = 1 + extra_headers; os->private = priv; AV_WL32(extradata + 0, overlap); From 90a29294169d8bc57dec2e0b600fe50c101ed625 Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Tue, 19 Apr 2011 23:36:29 +0200 Subject: [PATCH 059/172] oggparsecelt: cosmetic: order lines more logically. Signed-off-by: Nicolas George --- libavformat/oggparsecelt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c index 488fa28bed..bbb695f438 100644 --- a/libavformat/oggparsecelt.c +++ b/libavformat/oggparsecelt.c @@ -61,21 +61,21 @@ static int celt_header(AVFormatContext *s, int idx) overlap = AV_RL32(p + 48); bytes_per_packet = AV_RL32(p + 52); /* unused */ extra_headers = AV_RL32(p + 56); - av_free(os->private); - av_free(st->codec->extradata); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_CELT; st->codec->sample_rate = sample_rate; st->codec->channels = nb_channels; st->codec->frame_size = frame_size; st->codec->sample_fmt = AV_SAMPLE_FMT_S16; - st->codec->extradata = extradata; - st->codec->extradata_size = 2 * sizeof(uint32_t); av_set_pts_info(st, 64, 1, sample_rate); priv->extra_headers_left = 1 + extra_headers; + av_free(os->private); os->private = priv; AV_WL32(extradata + 0, overlap); AV_WL32(extradata + 4, version); + av_free(st->codec->extradata); + st->codec->extradata = extradata; + st->codec->extradata_size = 2 * sizeof(uint32_t); return 1; } else if(priv && priv->extra_headers_left) { From 37c0a443f9aa01fcf33215b3cde06961f1e9df5c Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Tue, 19 Apr 2011 15:23:36 -0700 Subject: [PATCH 060/172] Fix libx264 fastfirstpass, move apply_fastfirstpass after user customized options. --- libavcodec/libx264.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 5b20d35464..0ef42cd9ad 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -262,13 +262,6 @@ static av_cold int X264_init(AVCodecContext *avctx) return -1; } - if (x4->fastfirstpass) - x264_param_apply_fastfirstpass(&x4->params); - - if (x4->profile) - if (x264_param_apply_profile(&x4->params, x4->profile) < 0) - return -1; - x4->params.pf_log = X264_log; x4->params.p_log_private = avctx; x4->params.i_log_level = X264_LOG_DEBUG; @@ -302,6 +295,13 @@ static av_cold int X264_init(AVCodecContext *avctx) (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; } + if (x4->fastfirstpass) + x264_param_apply_fastfirstpass(&x4->params); + + if (x4->profile) + if (x264_param_apply_profile(&x4->params, x4->profile) < 0) + return -1; + x4->params.i_width = avctx->width; x4->params.i_height = avctx->height; x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num; From f92b0084c0e02b3c816a9eb234c548487acadae8 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Tue, 19 Apr 2011 16:12:13 -0700 Subject: [PATCH 061/172] In libx264 wrapper, add -level specific option. --- libavcodec/libx264.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 0ef42cd9ad..29c535c5bc 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -38,6 +38,7 @@ typedef struct X264Context { const char *preset; const char *tune; const char *profile; + const char *level; int fastfirstpass; } X264Context; @@ -163,6 +164,15 @@ static av_cold int X264_close(AVCodecContext *avctx) return 0; } +#define OPT_STR(opt, param) \ + do { \ + if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ + av_log(avctx, AV_LOG_ERROR, \ + "bad value for '%s': '%s'\n", opt, param); \ + return -1; \ + } \ + } while (0); \ + static av_cold int X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; @@ -249,9 +259,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_trellis = avctx->trellis; x4->params.analyse.i_noise_reduction = avctx->noise_reduction; - if (avctx->level > 0) - x4->params.i_level_idc = avctx->level; - x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); x4->params.rc.f_pb_factor = avctx->b_quant_factor; @@ -295,6 +302,8 @@ static av_cold int X264_init(AVCodecContext *avctx) (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; } + OPT_STR("level", x4->level); + if (x4->fastfirstpass) x264_param_apply_fastfirstpass(&x4->params); @@ -361,6 +370,7 @@ static const AVOption options[] = { {"tune", "Tune the encoding params", OFFSET(tune), FF_OPT_TYPE_STRING, 0, 0, 0, VE}, {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE}, {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, 0, 0, 0, VE}, + {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, 0, 0, 0, VE}, { NULL }, }; From 5efef54e70191ab20bcf89239255f1774bf2357c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 19 Apr 2011 19:48:44 +0200 Subject: [PATCH 062/172] Reflect 0.7_beta1 release in the Changelog --- Changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changelog b/Changelog index 4bc6d31d36..f38ef9eec5 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,11 @@ releases are sorted from youngest to oldest. version : +- Lots of deprecated API cruft removed + + +version 0.7_beta1: + - WebM support in Matroska de/muxer - low overhead Ogg muxing - MMS-TCP support From ddb00ad1d8aba9cdd9ae4b3156512c3f22e2c5a3 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 20 Apr 2011 09:44:08 +0200 Subject: [PATCH 063/172] Move the info union to the end of the vdpau_render_state struct. --- libavcodec/vdpau.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h index ab5f682c62..0dc6fb850b 100644 --- a/libavcodec/vdpau.h +++ b/libavcodec/vdpau.h @@ -67,6 +67,13 @@ struct vdpau_render_state { int state; ///< Holds FF_VDPAU_STATE_* values. + /** Describe size/location of the compressed video data. + Set to 0 when freeing bitstream_buffers. */ + int bitstream_buffers_allocated; + int bitstream_buffers_used; + /** The user is responsible for freeing this buffer using av_freep(). */ + VdpBitstreamBuffer *bitstream_buffers; + /** picture parameter information for all supported codecs */ union VdpPictureInfo { VdpPictureInfoH264 h264; @@ -74,13 +81,6 @@ struct vdpau_render_state { VdpPictureInfoVC1 vc1; VdpPictureInfoMPEG4Part2 mpeg4; } info; - - /** Describe size/location of the compressed video data. - Set to 0 when freeing bitstream_buffers. */ - int bitstream_buffers_allocated; - int bitstream_buffers_used; - /** The user is responsible for freeing this buffer using av_freep(). */ - VdpBitstreamBuffer *bitstream_buffers; }; /* @}*/ From 89451dd6e4da40ed73b8bbee2d48d8d8be1d5b0c Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Sat, 16 Apr 2011 17:45:30 +0200 Subject: [PATCH 064/172] Xiph CELT/Opus decoder using libcelt. Signed-off-by: Nicolas George --- configure | 5 ++ libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/libcelt_dec.c | 134 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 libavcodec/libcelt_dec.c diff --git a/configure b/configure index 6275648a0f..3cacb26412 100755 --- a/configure +++ b/configure @@ -161,6 +161,7 @@ Configuration options: External library support: --enable-avisynth enable reading of AVISynth script files [no] --enable-bzlib enable bzlib [autodetect] + --enable-libcelt enable CELT/Opus decoding via libcelt [no] --enable-frei0r enable frei0r video filtering --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no] --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no] @@ -929,6 +930,7 @@ CONFIG_LIST=" h264pred hardcoded_tables huffman + libcelt libdc1394 libdirac libfaac @@ -1393,6 +1395,7 @@ vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" h264_parser_select="golomb h264dsp h264pred" # external libraries +libcelt_decoder_deps="libcelt" libdirac_decoder_deps="libdirac !libschroedinger" libdirac_encoder_deps="libdirac" libfaac_encoder_deps="libfaac" @@ -2888,6 +2891,7 @@ check_mathfunc truncf # these are off by default, so fail if requested and not available enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32 +enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } enabled libdirac && require_pkg_config dirac \ "libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h" \ @@ -3167,6 +3171,7 @@ echo "threading support ${thread_type-no}" echo "SDL support ${sdl-no}" echo "Sun medialib support ${mlib-no}" echo "AVISynth enabled ${avisynth-no}" +echo "libcelt enabled ${libcelt-no}" echo "frei0r enabled ${frei0r-no}" echo "libdc1394 support ${libdc1394-no}" echo "libdirac enabled ${libdirac-no}" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index aa7390be19..df2cda03dc 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -553,6 +553,7 @@ OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \ mpegaudiodata.o # external codec libraries +OBJS-$(CONFIG_LIBCELT_DECODER) += libcelt_dec.o OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 56fa6280a2..eade67fb7a 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -365,6 +365,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (XSUB, xsub); /* external libraries */ + REGISTER_DECODER (LIBCELT, libcelt); REGISTER_ENCDEC (LIBDIRAC, libdirac); REGISTER_ENCODER (LIBFAAC, libfaac); REGISTER_ENCDEC (LIBGSM, libgsm); diff --git a/libavcodec/libcelt_dec.c b/libavcodec/libcelt_dec.c new file mode 100644 index 0000000000..3e52ab572e --- /dev/null +++ b/libavcodec/libcelt_dec.c @@ -0,0 +1,134 @@ +/* + * Xiph CELT / Opus decoder using libcelt + * Copyright (c) 2011 Nicolas George + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include "avcodec.h" +#include "libavutil/intreadwrite.h" + +struct libcelt_context { + CELTMode *mode; + CELTDecoder *dec; + int frame_bytes; + int discard; +}; + +static int ff_celt_error_to_averror(int err) +{ + switch(err) { + case CELT_BAD_ARG: return AVERROR(EINVAL); +#ifdef CELT_BUFFER_TOO_SMALL + case CELT_BUFFER_TOO_SMALL: return AVERROR(ENOBUFS); +#endif + case CELT_INTERNAL_ERROR: return AVERROR(EFAULT); + case CELT_CORRUPTED_DATA: return AVERROR_INVALIDDATA; + case CELT_UNIMPLEMENTED: return AVERROR(ENOTSUP); + case CELT_INVALID_STATE: return AVERROR(ENOTRECOVERABLE); + case CELT_ALLOC_FAIL: return AVERROR(ENOMEM); + default: return AVERROR_UNKNOWN; + } +} + +static int ff_celt_bitstream_version_hack(CELTMode *mode) +{ + CELTHeader header = { .version_id = 0 }; + celt_header_init(&header, mode, 960, 2); + return header.version_id; +} + +static av_cold int libcelt_dec_init(AVCodecContext *c) +{ + struct libcelt_context *celt = c->priv_data; + int err; + + if (!c->channels || !c->frame_size || + c->frame_size > INT_MAX / sizeof(int16_t) / c->channels) + return AVERROR(EINVAL); + celt->frame_bytes = c->frame_size * c->channels * sizeof(int16_t); + celt->mode = celt_mode_create(c->sample_rate, c->frame_size, &err); + if (!celt->mode) + return ff_celt_error_to_averror(err); + celt->dec = celt_decoder_create_custom(celt->mode, c->channels, &err); + if (!celt->dec) { + celt_mode_destroy(celt->mode); + return ff_celt_error_to_averror(err); + } + if (c->extradata_size >= 4) { + celt->discard = AV_RL32(c->extradata); + if (celt->discard < 0 || celt->discard >= c->frame_size) { + av_log(c, AV_LOG_WARNING, + "Invalid overlap (%d), ignored.\n", celt->discard); + celt->discard = 0; + } + celt->discard *= c->channels * sizeof(int16_t); + } + if(c->extradata_size >= 8) { + unsigned version = AV_RL32(c->extradata + 4); + unsigned lib_version = ff_celt_bitstream_version_hack(celt->mode); + if (version != lib_version) + av_log(c, AV_LOG_WARNING, + "CELT bitstream version 0x%x may be " + "improperly decoded by libcelt for version 0x%x.\n", + version, lib_version); + } + return 0; +} + +static av_cold int libcelt_dec_close(AVCodecContext *c) +{ + struct libcelt_context *celt = c->priv_data; + + celt_decoder_destroy(celt->dec); + celt_mode_destroy(celt->mode); + return 0; +} + +static int libcelt_dec_decode(AVCodecContext *c, void *pcm, int *pcm_size, + AVPacket *pkt) +{ + struct libcelt_context *celt = c->priv_data; + int err; + + if (*pcm_size < celt->frame_bytes) + return AVERROR(ENOBUFS); + err = celt_decode(celt->dec, pkt->data, pkt->size, pcm, c->frame_size); + if (err < 0) + return ff_celt_error_to_averror(err); + *pcm_size = celt->frame_bytes; + if (celt->discard) { + *pcm_size = celt->frame_bytes - celt->discard; + memmove(pcm, (char *)pcm + celt->discard, *pcm_size); + celt->discard = 0; + } + return pkt->size; +} + +AVCodec ff_libcelt_decoder = { + .name = "libcelt", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_CELT, + .priv_data_size = sizeof(struct libcelt_context), + .init = libcelt_dec_init, + .close = libcelt_dec_close, + .decode = libcelt_dec_decode, + .capabilities = 0, + .long_name = NULL_IF_CONFIG_SMALL("Xiph CELT/Opus decoder using libcelt"), +}; From a81ff195c15ccfa34f25b7b753c2e5438fe8939e Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 19 Apr 2011 21:53:48 +0200 Subject: [PATCH 065/172] libpostproc: Remove crufty code disabled by the big bump. --- libpostproc/postprocess.c | 4 ---- libpostproc/postprocess.h | 6 ------ 2 files changed, 10 deletions(-) diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index 73ffcb4a63..d7c99e29da 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -695,11 +695,7 @@ static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[] /* -pp Command line Help */ -#if LIBPOSTPROC_VERSION_INT < (52<<16) -const char *const pp_help= -#else const char pp_help[] = -#endif "Available postprocessing filters:\n" "Filters Options\n" "short long name short long option Description\n" diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h index 9e74589455..fe8c9b96ce 100644 --- a/libpostproc/postprocess.h +++ b/libpostproc/postprocess.h @@ -67,13 +67,7 @@ const char *postproc_license(void); typedef void pp_context; typedef void pp_mode; -#if LIBPOSTPROC_VERSION_INT < (52<<16) -typedef pp_context pp_context_t; -typedef pp_mode pp_mode_t; -extern const char *const pp_help; ///< a simple help text -#else extern const char pp_help[]; ///< a simple help text -#endif void pp_postprocess(const uint8_t * src[3], const int srcStride[3], uint8_t * dst[3], const int dstStride[3], From 8408e1d7d69aad57e633c27a6bcd522a15fa3702 Mon Sep 17 00:00:00 2001 From: Vladimir Pantelic Date: Wed, 20 Apr 2011 12:31:10 +0200 Subject: [PATCH 066/172] asf: remove commented out code in asf_read_seek Signed-off-by: Mans Rullgard --- libavformat/asfdec.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 8dc5291ff1..8e10d68b62 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1270,27 +1270,6 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int /* find the position */ pos = st->index_entries[index].pos; - // various attempts to find key frame have failed so far - // asf_reset_header(s); - // avio_seek(s->pb, pos, SEEK_SET); - // key_pos = pos; - // for(i=0;i<16;i++){ - // pos = avio_tell(s->pb); - // if (av_read_frame(s, &pkt) < 0){ - // av_log(s, AV_LOG_INFO, "seek failed\n"); - // return -1; - // } - // asf_st = s->streams[stream_index]->priv_data; - // pos += st->parser->frame_offset; - // - // if (pkt.size > b) { - // b = pkt.size; - // key_pos = pos; - // } - // - // av_free_packet(&pkt); - // } - /* do the seek */ av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos); avio_seek(s->pb, pos, SEEK_SET); From c60112f26873afafb55d24cc50a0e93ad9411373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 11:40:29 +0200 Subject: [PATCH 067/172] libavformat: Make protocols pass URLContext as log context where available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the libavformat major bump, URLContext contains an AVClass, making it a usable log context. Signed-off-by: Martin Storsjö --- libavformat/applehttpproto.c | 10 +++++----- libavformat/gopher.c | 2 +- libavformat/http.c | 4 ++-- libavformat/tcp.c | 4 ++-- libavformat/udp.c | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c index 8a9bcb1ade..37b289a1e0 100644 --- a/libavformat/applehttpproto.c +++ b/libavformat/applehttpproto.c @@ -195,7 +195,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags) av_strlcpy(s->playlisturl, "http://", sizeof(s->playlisturl)); av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl)); } else { - av_log(NULL, AV_LOG_ERROR, "Unsupported url %s\n", uri); + av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri); ret = AVERROR(EINVAL); goto fail; } @@ -218,7 +218,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags) } if (s->n_segments == 0) { - av_log(NULL, AV_LOG_WARNING, "Empty playlist\n"); + av_log(h, AV_LOG_WARNING, "Empty playlist\n"); ret = AVERROR(EIO); goto fail; } @@ -258,7 +258,7 @@ retry: return ret; } if (s->cur_seq_no < s->start_seq_no) { - av_log(NULL, AV_LOG_WARNING, + av_log(h, AV_LOG_WARNING, "skipping %d segments ahead, expired from playlist\n", s->start_seq_no - s->cur_seq_no); s->cur_seq_no = s->start_seq_no; @@ -274,12 +274,12 @@ retry: goto retry; } url = s->segments[s->cur_seq_no - s->start_seq_no]->url, - av_log(NULL, AV_LOG_DEBUG, "opening %s\n", url); + av_log(h, AV_LOG_DEBUG, "opening %s\n", url); ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ); if (ret < 0) { if (url_interrupt_cb()) return AVERROR_EXIT; - av_log(NULL, AV_LOG_WARNING, "Unable to open %s\n", url); + av_log(h, AV_LOG_WARNING, "Unable to open %s\n", url); s->cur_seq_no++; goto retry; } diff --git a/libavformat/gopher.c b/libavformat/gopher.c index 1d38cd232f..79d1feba6b 100644 --- a/libavformat/gopher.c +++ b/libavformat/gopher.c @@ -50,7 +50,7 @@ static int gopher_connect(URLContext *h, const char *path) if (!path) return AVERROR(EINVAL); break; default: - av_log(NULL, AV_LOG_WARNING, + av_log(h, AV_LOG_WARNING, "Gopher protocol type '%c' not supported yet!\n", *path); return AVERROR(EINVAL); diff --git a/libavformat/http.c b/libavformat/http.c index 190f844ea1..7d59152409 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -70,7 +70,7 @@ void ff_http_set_headers(URLContext *h, const char *headers) int len = strlen(headers); if (len && strcmp("\r\n", headers + len - 2)) - av_log(NULL, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n"); + av_log(h, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n"); av_strlcpy(s->headers, headers, sizeof(s->headers)); } @@ -232,7 +232,7 @@ static int process_line(URLContext *h, char *line, int line_count, * don't abort until all headers have been parsed. */ if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401) { end += strspn(end, SPACE_CHARS); - av_log(NULL, AV_LOG_WARNING, "HTTP error %d %s\n", + av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n", s->http_code, end); return -1; } diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 0cb3ae3262..ced103876f 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -64,7 +64,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) snprintf(portstr, sizeof(portstr), "%d", port); ret = getaddrinfo(hostname, portstr, &hints, &ai); if (ret) { - av_log(NULL, AV_LOG_ERROR, + av_log(h, AV_LOG_ERROR, "Failed to resolve hostname %s: %s\n", hostname, gai_strerror(ret)); return AVERROR(EIO); @@ -119,7 +119,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) optlen = sizeof(ret); getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen); if (ret != 0) { - av_log(NULL, AV_LOG_ERROR, + av_log(h, AV_LOG_ERROR, "TCP connection to %s:%d failed: %s\n", hostname, port, strerror(ret)); goto fail; diff --git a/libavformat/udp.c b/libavformat/udp.c index 76e3f1a4a2..932eb19c2d 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -266,7 +266,7 @@ int ff_udp_set_remote_url(URLContext *h, const char *uri) if (connect(s->udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) { s->is_connected = 0; - av_log(NULL, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); + av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); return AVERROR(EIO); } } @@ -410,7 +410,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) /* limit the tx buf size to limit latency */ tmp = s->buffer_size; if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) { - av_log(NULL, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno)); + av_log(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno)); goto fail; } } else { @@ -418,14 +418,14 @@ static int udp_open(URLContext *h, const char *uri, int flags) * avoid losing data on OSes that set this too low by default. */ tmp = s->buffer_size; if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) { - av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno)); + av_log(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno)); } /* make the socket non-blocking */ ff_socket_nonblock(udp_fd, 1); } if (s->is_connected) { if (connect(udp_fd, (struct sockaddr *) &s->dest_addr, s->dest_addr_len)) { - av_log(NULL, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); + av_log(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno)); goto fail; } } From 7bbb67d58005f3c0384f657570fabcdc0bc8cc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 12:03:55 +0300 Subject: [PATCH 068/172] libavformat: Free AVFormatContext->streams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After switching this from a statically allocated array to a dynamically allocated one in the major bump, this needs explicit freeing. Signed-off-by: Martin Storsjö --- libavformat/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index 0c80ff618e..19498b96a4 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2564,6 +2564,7 @@ void avformat_free_context(AVFormatContext *s) av_freep(&s->chapters); av_metadata_free(&s->metadata); av_freep(&s->key); + av_freep(&s->streams); av_free(s); } From 26f6b8c571bcff7b325c7d6cc226c625dd465f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 17:09:46 +0300 Subject: [PATCH 069/172] avio: Fix sanity checks in ffurl_read* This fixes e.g. reading data over HTTP, where the underlying socket is set to read/write. Signed-off-by: Anton Khirnov --- libavformat/avio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 074d3eeb86..0702aff007 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -289,14 +289,14 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int int ffurl_read(URLContext *h, unsigned char *buf, int size) { - if (h->flags & AVIO_FLAG_WRITE) + if (!(h->flags & AVIO_FLAG_READ)) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read); } int ffurl_read_complete(URLContext *h, unsigned char *buf, int size) { - if (h->flags & AVIO_FLAG_WRITE) + if (!(h->flags & AVIO_FLAG_READ)) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read); } From 52512d0a4340895ba8bd9d2af48f256b969559d2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 12 Apr 2011 04:22:31 +0000 Subject: [PATCH 070/172] oggdec: use av_freep() instead of av_free() Signed-off-by: Anton Khirnov --- libavformat/oggdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index ce1152d3c2..d2725792e9 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -245,8 +245,8 @@ ogg_read_page (AVFormatContext * s, int *str) int n; for (n = 0; n < ogg->nstreams; n++) { - av_free(ogg->streams[n].buf); - av_free(ogg->streams[n].private); + av_freep(&ogg->streams[n].buf); + av_freep(&ogg->streams[n].private); } ogg->curidx = -1; ogg->nstreams = 0; From 14e3b120adb6e3c0337ffce2f595f85f2a1f33a2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 23 Mar 2011 04:31:01 +0000 Subject: [PATCH 071/172] Reduce picture size for yadif. Signed-off-by: Anton Khirnov --- libavfilter/vf_yadif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 176349a5c4..7a488d6aaa 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -150,7 +150,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, { AVFilterBufferRef *picref; int width = FFALIGN(w, 32); - int height= FFALIGN(h+6, 32); + int height= FFALIGN(h+2, 32); int i; picref = avfilter_default_get_video_buffer(link, perms, width, height); @@ -159,7 +159,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, picref->video->h = h; for (i = 0; i < 3; i++) - picref->data[i] += 3 * picref->linesize[i]; + picref->data[i] += picref->linesize[i]; return picref; } From 53f7628d38b8884016042f0d9527c71611d9182e Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 19 Apr 2011 19:37:29 -0400 Subject: [PATCH 072/172] update last major version increase dates in APIchanges --- doc/APIchanges | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 2c0d58519e..a9faaf927c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -1,13 +1,13 @@ Never assume the API of libav* to be stable unless at least 1 week has passed since the last major version increase. The last version increases were: -libavcodec: ? -libavdevice: ? -libavfilter: 2009-10-18 -libavformat: ? -libpostproc: ? -libswscale: ? -libavutil: 2009-03-08 +libavcodec: 2011-04-18 +libavdevice: 2011-04-18 +libavfilter: 2011-04-18 +libavformat: 2011-04-18 +libpostproc: 2011-04-18 +libswscale: 2011-04-18 +libavutil: 2011-04-18 API changes, most recent first: From b9553cf4b80d79c280ae7c989593ce1daac4cafa Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Wed, 20 Apr 2011 18:13:54 +0200 Subject: [PATCH 073/172] avio: fix AVIO_FLAG_READ/WRITE test in ffurl_*. Signed-off-by: Nicolas George --- libavformat/avio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 0a09cf1c44..936a3d979c 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -287,14 +287,14 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int int ffurl_read(URLContext *h, unsigned char *buf, int size) { - if (h->flags & AVIO_FLAG_WRITE) + if (!(h->flags & AVIO_FLAG_READ)) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read); } int ffurl_read_complete(URLContext *h, unsigned char *buf, int size) { - if (h->flags & AVIO_FLAG_WRITE) + if (!(h->flags & AVIO_FLAG_READ)) return AVERROR(EIO); return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read); } From 63de9e7d80ac3609fe378c5cadd5e899185846a7 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 20 Apr 2011 17:18:27 +0200 Subject: [PATCH 074/172] Remove a version check in av_log made unnecessary by the big bump. --- libavutil/log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/log.c b/libavutil/log.c index 72d2b914bd..deab11965d 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -91,7 +91,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) line[0]=0; #undef fprintf if(print_prefix && avc) { - if(avc->version >= (50<<16 | 15<<8 | 3) && avc->parent_log_context_offset){ + if (avc->parent_log_context_offset) { AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); if(parent && *parent){ snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent); From f83acb096c0ea1ec181941c141d1ab6fb24820eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 21:22:08 +0300 Subject: [PATCH 075/172] Makefile: Include dependencies for test tools, too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes seek_test to be rebuilt when its dependencies has changed. The changes to the dependencies didn't usually matter in practice, but the introduction of side data in AVPacket required a recompilation. Signed-off-by: Martin Storsjö --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 0bf04d1d02..f8e68d6c49 100644 --- a/Makefile +++ b/Makefile @@ -87,6 +87,7 @@ tools/%.o: tools/%.c $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $< -include $(wildcard tools/*.d) +-include $(wildcard tests/*.d) ffplay.o: CFLAGS += $(SDL_CFLAGS) From 2c18893a911657205bd45ff8a666882610e57700 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Wed, 20 Apr 2011 15:46:20 -0700 Subject: [PATCH 076/172] In libx264 wrapper, correctly support 2pass log filename option. --- ffmpeg.c | 12 +++++++++--- libavcodec/libx264.c | 13 +++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index ec0a0235d1..b91e9d3ea3 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -207,7 +207,7 @@ static int do_hex_dump = 0; static int do_pkt_dump = 0; static int do_psnr = 0; static int do_pass = 0; -static char *pass_logfilename_prefix = NULL; +static const char *pass_logfilename_prefix; static int audio_stream_copy = 0; static int video_stream_copy = 0; static int subtitle_stream_copy = 0; @@ -2331,7 +2331,7 @@ static int transcode(AVFormatContext **output_files, break; } /* two pass mode */ - if (ost->encoding_needed && + if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; @@ -4268,6 +4268,12 @@ static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl) { } +static void opt_passlogfile(const char *arg) +{ + pass_logfilename_prefix = arg; + opt_default("passlogfile", arg); +} + static const OptionDef options[] = { /* main options */ #include "cmdutils_common_opts.h" @@ -4341,7 +4347,7 @@ static const OptionDef options[] = { { "sameq", OPT_BOOL | OPT_VIDEO, {(void*)&same_quality}, "use same quantizer as source (implies VBR)" }, { "pass", HAS_ARG | OPT_FUNC2 | OPT_VIDEO, {(void*)opt_pass}, "select the pass number (1 or 2)", "n" }, - { "passlogfile", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void*)&pass_logfilename_prefix}, "select two pass log file name prefix", "prefix" }, + { "passlogfile", HAS_ARG | OPT_VIDEO, {(void*)&opt_passlogfile}, "select two pass log file name prefix", "prefix" }, { "deinterlace", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_deinterlace}, "deinterlace pictures" }, { "psnr", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_psnr}, "calculate PSNR of compressed frames" }, diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 29c535c5bc..bd85e060c6 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -40,6 +40,7 @@ typedef struct X264Context { const char *profile; const char *level; int fastfirstpass; + const char *stats; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -164,6 +165,15 @@ static av_cold int X264_close(AVCodecContext *avctx) return 0; } +#define OPT_STR(opt, param) \ + do { \ + if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ + av_log(avctx, AV_LOG_ERROR, \ + "bad value for '%s': '%s'\n", opt, param); \ + return -1; \ + } \ + } while (0); \ + #define OPT_STR(opt, param) \ do { \ if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ @@ -291,6 +301,8 @@ static av_cold int X264_init(AVCodecContext *avctx) } } + OPT_STR("stats", x4->stats); + // if neither crf nor cqp modes are selected we have to enable the RC // we do it this way because we cannot check if the bitrate has been set if (!(avctx->crf || (avctx->cqp > -1))) @@ -371,6 +383,7 @@ static const AVOption options[] = { {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE}, {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, 0, 0, 0, VE}, {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, 0, 0, 0, VE}, + {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), FF_OPT_TYPE_STRING, 0, 0, 0, VE}, { NULL }, }; From 58f8463947e56dc448baeeabd7875ea90bdb4a98 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 11 Apr 2011 00:52:04 +0200 Subject: [PATCH 077/172] error: add error code AVERROR_OPTION_NOT_FOUND, and use it in opt.c The new error code is better than AVERROR(ENOENT), which has a completely different semantics ("No such file or directory"). Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- libavutil/error.c | 1 + libavutil/error.h | 1 + libavutil/opt.c | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavutil/error.c b/libavutil/error.c index 978e5431e9..3c3f03fe9b 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -33,6 +33,7 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found"; break; case AVERROR_DECODER_NOT_FOUND: errstr = "Decoder not found"; break; case AVERROR_ENCODER_NOT_FOUND: errstr = "Encoder not found"; break; + case AVERROR_OPTION_NOT_FOUND: errstr = "Option not found"; break; case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found"; break; case AVERROR_FILTER_NOT_FOUND: errstr = "Filter not found"; break; case AVERROR_BSF_NOT_FOUND: errstr = "Bitstream filter not found"; break; diff --git a/libavutil/error.h b/libavutil/error.h index 33332b18c4..23e0b01789 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -48,6 +48,7 @@ #define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found #define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found #define AVERROR_ENCODER_NOT_FOUND (-MKTAG(0xF8,'E','N','C')) ///< Encoder not found +#define AVERROR_OPTION_NOT_FOUND (-MKTAG(0xF8,'O','P','T')) ///< Option not found #define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found #define AVERROR_FILTER_NOT_FOUND (-MKTAG(0xF8,'F','I','L')) ///< Filter not found #define AVERROR_BSF_NOT_FOUND (-MKTAG(0xF8,'B','S','F')) ///< Bitstream filter not found diff --git a/libavutil/opt.c b/libavutil/opt.c index 30efb52ddd..f08ed8f068 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -57,7 +57,7 @@ static int av_set_number2(void *obj, const char *name, double num, int den, int6 if (o_out) *o_out= o; if (!o || o->offset<=0) - return AVERROR(ENOENT); + return AVERROR_OPTION_NOT_FOUND; if (o->max*den < num*intnum || o->min*den > num*intnum) { av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name); @@ -119,7 +119,7 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons if (o_out) *o_out = o; if (!o) - return AVERROR(ENOENT); + return AVERROR_OPTION_NOT_FOUND; if (!val || o->offset<=0) return AVERROR(EINVAL); @@ -490,7 +490,7 @@ static int parse_key_value_pair(void *ctx, const char **buf, av_log(ctx, AV_LOG_DEBUG, "Setting value '%s' for key '%s'\n", val, key); ret = av_set_string3(ctx, key, val, 1, NULL); - if (ret == AVERROR(ENOENT)) + if (ret == AVERROR_OPTION_NOT_FOUND) av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key); av_free(key); From 79157f400bec7fdb6385befa63fdafc727378143 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 11 Apr 2011 00:29:30 +0200 Subject: [PATCH 078/172] error: remove AVERROR_NUMEXPECTED AVERROR_NUMEXPECTED is used only in the image muxer and demuxer, and has a too much specific meaning, which is better explained through a log message. Thus it can be replaced by AVERROR(EINVAL). This breaks API. Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- ffmpeg.c | 2 +- libavformat/utils.c | 2 +- libavutil/error.c | 1 - libavutil/error.h | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 6e620bf55e..886d5da7de 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3722,7 +3722,7 @@ static void opt_output_file(const char *filename) /* check filename in case of an image number is expected */ if (oc->oformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(oc->filename)) { - print_error(oc->filename, AVERROR_NUMEXPECTED); + print_error(oc->filename, AVERROR(EINVAL)); ffmpeg_exit(1); } } diff --git a/libavformat/utils.c b/libavformat/utils.c index 19498b96a4..88e9a49e87 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -581,7 +581,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, /* check filename in case an image number is expected */ if (fmt->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(filename)) { - err = AVERROR_NUMEXPECTED; + err = AVERROR(EINVAL); goto fail; } } diff --git a/libavutil/error.c b/libavutil/error.c index 3c3f03fe9b..252007a6c9 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -27,7 +27,6 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) switch (errnum) { case AVERROR_EOF: errstr = "End of file"; break; case AVERROR_INVALIDDATA: errstr = "Invalid data found when processing input"; break; - case AVERROR_NUMEXPECTED: errstr = "Number syntax expected in filename"; break; case AVERROR_PATCHWELCOME: errstr = "Not yet implemented in Libav, patches welcome"; break; case AVERROR_DEMUXER_NOT_FOUND: errstr = "Demuxer not found"; break; case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found"; break; diff --git a/libavutil/error.h b/libavutil/error.h index 23e0b01789..62e75e136d 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -42,7 +42,6 @@ #define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in Libav, patches welcome #define AVERROR_INVALIDDATA (-MKTAG('I','N','D','A')) ///< Invalid data found when processing input -#define AVERROR_NUMEXPECTED (-MKTAG('N','U','E','X')) ///< Number syntax expected in filename #define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found #define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found From a975dbc86b97a421e51ac7075b8df869915745a2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 20 Apr 2011 07:14:50 +0200 Subject: [PATCH 079/172] error: change AVERROR_EOF value The current value is masking the POSIX error code EPIPE, which has a different semantics. This breaks API. Signed-off-by: Stefano Sabatini Signed-off-by: Anton Khirnov --- libavutil/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/error.h b/libavutil/error.h index 62e75e136d..a422f8555c 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -37,7 +37,7 @@ #define AVUNERROR(e) (e) #endif -#define AVERROR_EOF AVERROR(EPIPE) ///< End of file +#define AVERROR_EOF (-MKTAG('E','O','F',' ')) ///< End of file #define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in Libav, patches welcome From 095290f9a4230698f64c56b5ee9d89c046f6dd5b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 20 Apr 2011 17:09:45 +0200 Subject: [PATCH 080/172] lavc: provide the opt.h header until the next bump AVOptions were moved to libavutil only recently. --- libavcodec/Makefile | 2 +- libavcodec/opt.h | 16 ++++++++++++++++ libavcodec/version.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 libavcodec/opt.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f05244ed95..784226f7af 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak NAME = avcodec FFLIBS = avutil -HEADERS = avcodec.h avfft.h dxva2.h vaapi.h vdpau.h version.h xvmc.h +HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h version.h xvmc.h OBJS = allcodecs.o \ audioconvert.o \ diff --git a/libavcodec/opt.h b/libavcodec/opt.h new file mode 100644 index 0000000000..e754bb93d8 --- /dev/null +++ b/libavcodec/opt.h @@ -0,0 +1,16 @@ +/** + * @file + * This header is provided for compatibility only and will be removed + * on next major bump + */ + +#ifndef AVCODEC_OPT_H +#define AVCODEC_OPT_H + +#include "libavcodec/version.h" + +#if FF_API_OPT_H +#include "libavutil/opt.h" +#endif + +#endif diff --git a/libavcodec/version.h b/libavcodec/version.h index 3146f765ee..92f9e58ffa 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -62,5 +62,8 @@ #ifndef FF_API_REQUEST_CHANNELS #define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_OPT_H +#define FF_API_OPT_H (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 65af48b55930abe5ac9130be3ff4d9c287a7f010 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 20 Apr 2011 17:21:39 +0200 Subject: [PATCH 081/172] lavc: provide deprecated avcodec_thread_init until next major version It was deprecated only recently. --- libavcodec/avcodec.h | 8 ++++++++ libavcodec/utils.c | 8 ++++++++ libavcodec/version.h | 3 +++ 3 files changed, 19 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 40d3b2245b..7727ad08bf 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3577,6 +3577,14 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); +#if FF_API_THREAD_INIT +/** + * @deprecated Set s->thread_count before calling avcodec_open() instead of calling this. + */ +attribute_deprecated +int avcodec_thread_init(AVCodecContext *s, int thread_count); +#endif + int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); //FIXME func typedef diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0190e6652c..744e0ada87 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1220,3 +1220,11 @@ void ff_thread_await_progress(AVFrame *f, int progress, int field) } #endif + +#if FF_API_THREAD_INIT +int avcodec_thread_init(AVCodecContext *s, int thread_count) +{ + s->thread_count = thread_count; + return ff_thread_init(s); +} +#endif diff --git a/libavcodec/version.h b/libavcodec/version.h index 92f9e58ffa..b9c219d260 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -65,5 +65,8 @@ #ifndef FF_API_OPT_H #define FF_API_OPT_H (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_THREAD_INIT +#define FF_API_THREAD_INIT (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ From 6d6351483fe94b7ae4938717b477014f42500145 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 10:31:48 +0200 Subject: [PATCH 082/172] ocv: replace FF_INTERNAL_MEM_TYPE_MAX_VALUE with SIZE_MAX Fix compilatin after removal of FF_INTERNAL_MEM_TYPE_MAX_VALUE. Signed-off-by: Stefano Sabatini --- libavfilter/vf_libopencv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index 8401b4dcb7..55e0a7f757 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -158,7 +158,7 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char * } w++; } - if (*rows > (FF_INTERNAL_MEM_TYPE_MAX_VALUE / (sizeof(int)) / *cols)) { + if (*rows > (SIZE_MAX / sizeof(int) / *cols)) { av_log(log_ctx, AV_LOG_ERROR, "File with size %dx%d is too big\n", *rows, *cols); return AVERROR_INVALIDDATA; From 7046b63e69a5a49a8f575d89d8f0fc6680975382 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 20 Apr 2011 13:13:09 +0200 Subject: [PATCH 083/172] ffmpeg: call pre_process_video_frame() only if decoding is needed In output_packet(), move the pre_process_video_frame() call inside the if (ist->decoding_needed) { } block. This way pre_process_video_frame() is not called when stream-copy has been selected. Also simplify. Signed-off-by: Stefano Sabatini --- ffmpeg.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index b91e9d3ea3..d2232857c1 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1489,7 +1489,7 @@ static int output_packet(AVInputStream *ist, int ist_index, int ret, i; int got_picture; AVFrame picture; - void *buffer_to_free; + void *buffer_to_free = NULL; static unsigned int samples_size= 0; AVSubtitle subtitle, *subtitle_to_free; int64_t pkt_pts = AV_NOPTS_VALUE; @@ -1590,6 +1590,8 @@ static int output_packet(AVInputStream *ist, int ist_index, ist->st->codec->time_base.den; } avpkt.size = 0; + buffer_to_free = NULL; + pre_process_video_frame(ist, (AVPicture *)&picture, &buffer_to_free); break; case AVMEDIA_TYPE_SUBTITLE: ret = avcodec_decode_subtitle2(ist->st->codec, @@ -1624,12 +1626,6 @@ static int output_packet(AVInputStream *ist, int ist_index, avpkt.size = 0; } - buffer_to_free = NULL; - if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { - pre_process_video_frame(ist, (AVPicture *)&picture, - &buffer_to_free); - } - #if CONFIG_AVFILTER if(ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ for(i=0;i Date: Mon, 11 Apr 2011 00:39:59 +0200 Subject: [PATCH 084/172] img2: return AVERROR(EINVAL) in case of invalid filename pattern In write_packet(), return AVERROR(EINVAL) rather than AVERROR(EIO) if the provided output filename pattern is not valid. Indeed this has to be considered a configuration error rather than an I/O error. Allow a less confusing error report. Signed-off-by: Stefano Sabatini --- libavformat/img2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/img2.c b/libavformat/img2.c index bff06018fa..0de2f8b9ed 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -366,7 +366,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) av_log(s, AV_LOG_ERROR, "Could not get frame filename number %d from pattern '%s'\n", img->img_number, img->path); - return AVERROR(EIO); + return AVERROR(EINVAL); } for(i=0; i<3; i++){ if (avio_open(&pb[i], filename, AVIO_FLAG_WRITE) < 0) { From 32a128522ad392d2bca67165fda1d2fe30262189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 21 Apr 2011 13:49:21 +0300 Subject: [PATCH 085/172] libavdevice: Define _XOPEN_SOURCE for usleep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This hopefully fixes build failures on Dragonfly BSD. Signed-off-by: Martin Storsjö --- libavdevice/bktr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 3e705a0247..ab70a1b2b7 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -26,6 +26,7 @@ #define _BSD_SOURCE 1 #define _NETBSD_SOURCE +#define _XOPEN_SOURCE 600 #include "libavformat/avformat.h" #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H From 23d3931a6a8a37bb7e86bd6cb4709eb46031bfe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 21 Apr 2011 13:02:38 +0200 Subject: [PATCH 086/172] Provide a fallback version of the libm function trunc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes compilation on DOS. Signed-off-by: Martin Storsjö --- configure | 2 ++ libavutil/libm.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/configure b/configure index 32c3544fb3..dd44ba4739 100755 --- a/configure +++ b/configure @@ -1119,6 +1119,7 @@ HAVE_LIST=" sys_videoio_h ten_operands threads + trunc truncf vfp_args VirtualAlloc @@ -2852,6 +2853,7 @@ check_mathfunc lrint check_mathfunc lrintf check_mathfunc round check_mathfunc roundf +check_mathfunc trunc check_mathfunc truncf # these are off by default, so fail if requested and not available diff --git a/libavutil/libm.h b/libavutil/libm.h index 704bcf9554..783f3cdfab 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -86,6 +86,13 @@ static av_always_inline av_const float roundf(float x) } #endif /* HAVE_ROUNDF */ +#if !HAVE_TRUNC +static av_always_inline av_const double trunc(double x) +{ + return (x > 0) ? floor(x) : ceil(x); +} +#endif /* HAVE_TRUNC */ + #if !HAVE_TRUNCF static av_always_inline av_const float truncf(float x) { From cac275791994be44b7a6d11a3878646e78ab5653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 23:04:31 +0300 Subject: [PATCH 087/172] doc: Add some initial docs on the applehttp demuxer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/demuxers.texi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index bbdde9c92d..4168fc10c6 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -64,4 +64,13 @@ Note that the pattern must not necessarily contain "%d" or ffmpeg -f image2 -i img.jpeg img.png @end example +@section applehttp + +Apple HTTP Live Streaming demuxer. + +This demuxer presents all AVStreams from all variant streams. +The id field is set to the bitrate variant index number. By setting +the discard flags on AVStreams (by pressing 'a' or 'v' in ffplay), +the caller can decide which variant streams to actually receive. + @c man end INPUT DEVICES From fe8e039460064ad765c37736dadd123478c5ff1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 10:10:10 +0300 Subject: [PATCH 088/172] applehttp: Expose the stream bitrate via metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helps callers to intelligently switch between bitrate variants. Signed-off-by: Martin Storsjö --- doc/demuxers.texi | 2 ++ libavformat/applehttp.c | 3 +++ libavformat/avformat.h | 1 + libavformat/version.h | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 4168fc10c6..98f9fdeff8 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -72,5 +72,7 @@ This demuxer presents all AVStreams from all variant streams. The id field is set to the bitrate variant index number. By setting the discard flags on AVStreams (by pressing 'a' or 'v' in ffplay), the caller can decide which variant streams to actually receive. +The total bitrate of the variant that the stream belongs to is +available in a metadata key named "variant_bitrate". @c man end INPUT DEVICES diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index df4494a785..90b86a8733 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -367,6 +367,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) for (i = 0; i < c->n_variants; i++) { struct variant *v = c->variants[i]; AVInputFormat *in_fmt = NULL; + char bitrate_str[20]; if (v->n_segments == 0) continue; @@ -393,6 +394,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) if (ret < 0) goto fail; v->stream_offset = stream_offset; + snprintf(bitrate_str, sizeof(bitrate_str), "%d", v->bandwidth); /* Create new AVStreams for each stream in this variant */ for (j = 0; j < v->ctx->nb_streams; j++) { AVStream *st = av_new_stream(s, i); @@ -401,6 +403,7 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; } avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); + av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str, 0); } stream_offset += v->ctx->nb_streams; } diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 2567aabd5a..732756222e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -104,6 +104,7 @@ struct AVFormatContext; * service_provider -- name of the service provider in broadcasting. * title -- name of the work. * track -- number of this work in the set, can be in form current/total. + * variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of */ #define AV_METADATA_MATCH_CASE 1 diff --git a/libavformat/version.h b/libavformat/version.h index 01730183b2..04c5d73f50 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -25,7 +25,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MINOR 0 -#define LIBAVFORMAT_VERSION_MICRO 0 +#define LIBAVFORMAT_VERSION_MICRO 1 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From ab1adff73f4852d99f9c65ef5a5ceca3e2accbe8 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 21 Apr 2011 15:56:55 +0200 Subject: [PATCH 089/172] The stabilization period after version bumps should be one month, not one week. --- doc/APIchanges | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a9faaf927c..24ba7b143b 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -1,5 +1,6 @@ -Never assume the API of libav* to be stable unless at least 1 week has passed since -the last major version increase. +Never assume the API of libav* to be stable unless at least 1 month has passed +since the last major version increase. + The last version increases were: libavcodec: 2011-04-18 libavdevice: 2011-04-18 From 8d67218bd73744c367450d8b8ecc5a6e6c42bd11 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 13:36:12 +0200 Subject: [PATCH 090/172] error: sort, pack, and align error code and string definitions Signed-off-by: Diego Biurrun --- libavutil/error.c | 24 ++++++++++++------------ libavutil/error.h | 26 +++++++++++--------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/libavutil/error.c b/libavutil/error.c index 252007a6c9..ddcc038650 100644 --- a/libavutil/error.c +++ b/libavutil/error.c @@ -25,19 +25,19 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size) const char *errstr = NULL; switch (errnum) { - case AVERROR_EOF: errstr = "End of file"; break; - case AVERROR_INVALIDDATA: errstr = "Invalid data found when processing input"; break; + case AVERROR_BSF_NOT_FOUND: errstr = "Bitstream filter not found" ; break; + case AVERROR_DECODER_NOT_FOUND: errstr = "Decoder not found" ; break; + case AVERROR_DEMUXER_NOT_FOUND: errstr = "Demuxer not found" ; break; + case AVERROR_ENCODER_NOT_FOUND: errstr = "Encoder not found" ; break; + case AVERROR_EOF: errstr = "End of file" ; break; + case AVERROR_EXIT: errstr = "Immediate exit requested" ; break; + case AVERROR_FILTER_NOT_FOUND: errstr = "Filter not found" ; break; + case AVERROR_INVALIDDATA: errstr = "Invalid data found when processing input" ; break; + case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found" ; break; + case AVERROR_OPTION_NOT_FOUND: errstr = "Option not found" ; break; case AVERROR_PATCHWELCOME: errstr = "Not yet implemented in Libav, patches welcome"; break; - case AVERROR_DEMUXER_NOT_FOUND: errstr = "Demuxer not found"; break; - case AVERROR_MUXER_NOT_FOUND: errstr = "Muxer not found"; break; - case AVERROR_DECODER_NOT_FOUND: errstr = "Decoder not found"; break; - case AVERROR_ENCODER_NOT_FOUND: errstr = "Encoder not found"; break; - case AVERROR_OPTION_NOT_FOUND: errstr = "Option not found"; break; - case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found"; break; - case AVERROR_FILTER_NOT_FOUND: errstr = "Filter not found"; break; - case AVERROR_BSF_NOT_FOUND: errstr = "Bitstream filter not found"; break; - case AVERROR_STREAM_NOT_FOUND: errstr = "Stream not found"; break; - case AVERROR_EXIT: errstr = "Immediate exit requested"; break; + case AVERROR_PROTOCOL_NOT_FOUND:errstr = "Protocol not found" ; break; + case AVERROR_STREAM_NOT_FOUND: errstr = "Stream not found" ; break; } if (errstr) { diff --git a/libavutil/error.h b/libavutil/error.h index a422f8555c..ba12d2bfae 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -37,24 +37,20 @@ #define AVUNERROR(e) (e) #endif -#define AVERROR_EOF (-MKTAG('E','O','F',' ')) ///< End of file - -#define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in Libav, patches welcome - -#define AVERROR_INVALIDDATA (-MKTAG('I','N','D','A')) ///< Invalid data found when processing input - -#define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found -#define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found -#define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found -#define AVERROR_ENCODER_NOT_FOUND (-MKTAG(0xF8,'E','N','C')) ///< Encoder not found -#define AVERROR_OPTION_NOT_FOUND (-MKTAG(0xF8,'O','P','T')) ///< Option not found -#define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found -#define AVERROR_FILTER_NOT_FOUND (-MKTAG(0xF8,'F','I','L')) ///< Filter not found #define AVERROR_BSF_NOT_FOUND (-MKTAG(0xF8,'B','S','F')) ///< Bitstream filter not found +#define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found +#define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found +#define AVERROR_ENCODER_NOT_FOUND (-MKTAG(0xF8,'E','N','C')) ///< Encoder not found +#define AVERROR_EOF (-MKTAG( 'E','O','F',' ')) ///< End of file +#define AVERROR_EXIT (-MKTAG( 'E','X','I','T')) ///< Immediate exit was requested; the called function should not be restarted +#define AVERROR_FILTER_NOT_FOUND (-MKTAG(0xF8,'F','I','L')) ///< Filter not found +#define AVERROR_INVALIDDATA (-MKTAG( 'I','N','D','A')) ///< Invalid data found when processing input +#define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found +#define AVERROR_OPTION_NOT_FOUND (-MKTAG(0xF8,'O','P','T')) ///< Option not found +#define AVERROR_PATCHWELCOME (-MKTAG( 'P','A','W','E')) ///< Not yet implemented in Libav, patches welcome +#define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found #define AVERROR_STREAM_NOT_FOUND (-MKTAG(0xF8,'S','T','R')) ///< Stream not found -#define AVERROR_EXIT (-MKTAG('E','X','I','T')) ///< Immediate exit was requested; the called function should not be restarted - /** * Put a description of the AVERROR code errnum in errbuf. * In case of failure the global variable errno is set to indicate the From 20a160484f33e0d6b40ce905a89c5c6e8282704b Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Thu, 21 Apr 2011 09:01:31 -0700 Subject: [PATCH 091/172] In libx264 wrapper, detect default settings and use medium profile to avoid failure. --- libavcodec/libx264.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index bd85e060c6..c1e60e6d5f 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -165,6 +165,31 @@ static av_cold int X264_close(AVCodecContext *avctx) return 0; } +/** + * Detect default settings and use default profile to avoid libx264 failure. + */ +static void check_default_settings(AVCodecContext *avctx) +{ + X264Context *x4 = avctx->priv_data; + + int score = 0; + score += x4->params.analyse.i_me_range == 0; + score += x4->params.rc.i_qp_step == 3; + score += x4->params.i_keyint_max == 12; + score += x4->params.rc.i_qp_min == 2; + score += x4->params.rc.i_qp_max == 31; + score += x4->params.rc.f_qcompress == 0.5; + score += fabs(x4->params.rc.f_ip_factor - 1.25) < 0.01; + score += fabs(x4->params.rc.f_pb_factor - 1.25) < 0.01; + score += x4->params.analyse.inter == 0 && x4->params.analyse.i_subpel_refine == 8; + if (score >= 5) { + av_log(avctx, AV_LOG_ERROR, "Default settings detected, using medium profile\n"); + x4->preset = "medium"; + if (avctx->bit_rate == 200*100) + avctx->crf = 23; + } +} + #define OPT_STR(opt, param) \ do { \ if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ @@ -274,6 +299,9 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.rc.f_pb_factor = avctx->b_quant_factor; x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; + if (!x4->preset) + check_default_settings(avctx); + if (x4->preset || x4->tune) { if (x264_param_default_preset(&x4->params, x4->preset, x4->tune) < 0) return -1; From e40cfb1463fbc3470a2c10670fd2bba8e9304ff4 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 14:25:25 +0200 Subject: [PATCH 092/172] mp: remove use of deprecated old eval API The old API was deprecated and will be possibly removed, fix warnings in libavfilter/libmpcodecs/vf_geq.c and libavfilter/libmpcodecs/vf_qp.c. Signed-off-by: Stefano Sabatini --- libavfilter/libmpcodecs/vf_geq.c | 4 ++-- libavfilter/libmpcodecs/vf_qp.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/libmpcodecs/vf_geq.c b/libavfilter/libmpcodecs/vf_geq.c index ffbb42c331..2102c87f55 100644 --- a/libavfilter/libmpcodecs/vf_geq.c +++ b/libavfilter/libmpcodecs/vf_geq.c @@ -116,7 +116,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ const_values[3]=y; for(x=0; xpriv->e[plane], + dst[x + y * dst_stride] = av_expr_eval(vf->priv->e[plane], const_values, vf); } } @@ -176,7 +176,7 @@ static int vf_open(vf_instance_t *vf, char *args){ plane==0 ? lum : (plane==1 ? cb : cr), NULL }; - res = av_parse_expr(&vf->priv->e[plane], eq[plane], const_names, NULL, NULL, func2_names, func2, 0, NULL); + res = av_expr_parse(&vf->priv->e[plane], eq[plane], const_names, NULL, NULL, func2_names, func2, 0, NULL); if (res < 0) { mp_msg(MSGT_VFILTER, MSGL_ERR, "geq: error loading equation `%s'\n", eq[plane]); diff --git a/libavfilter/libmpcodecs/vf_qp.c b/libavfilter/libmpcodecs/vf_qp.c index 25cd90de40..d74f138662 100644 --- a/libavfilter/libmpcodecs/vf_qp.c +++ b/libavfilter/libmpcodecs/vf_qp.c @@ -69,7 +69,7 @@ static int config(struct vf_instance *vf, double temp_val; int res; - res= av_parse_and_eval_expr(&temp_val, vf->priv->eq, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); + res= av_expr_parse_and_eval(&temp_val, vf->priv->eq, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); if (res < 0){ mp_msg(MSGT_VFILTER, MSGL_ERR, "qp: Error evaluating \"%s\" \n", vf->priv->eq); From 3eb15d98122e71faf98f22bc4acc7ab56f2f4858 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 18:44:47 +0200 Subject: [PATCH 093/172] mp: remove unused variable outlink in end_frame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning: vf_mp.c: In function ‘end_frame’: vf_mp.c:870: warning: unused variable ‘outlink’ Signed-off-by: Stefano Sabatini --- libavfilter/vf_mp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavfilter/vf_mp.c b/libavfilter/vf_mp.c index 374acac20f..866dbb16d2 100644 --- a/libavfilter/vf_mp.c +++ b/libavfilter/vf_mp.c @@ -867,7 +867,6 @@ static void end_frame(AVFilterLink *inlink) { MPContext *m = inlink->dst->priv; AVFilterBufferRef *inpic = inlink->cur_buf; - AVFilterLink *outlink = inlink->dst->outputs[0]; int i; double pts= MP_NOPTS_VALUE; mp_image_t* mpi = new_mp_image(inpic->video->w, inpic->video->h); From 70fb031ce27ce200026de2ea77ec038e2c2e141f Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 21 Apr 2011 19:38:49 +0200 Subject: [PATCH 094/172] Use av_log_ask_for_sample() where appropriate. --- libavcodec/cook.c | 12 ++++++------ libavcodec/truemotion1.c | 4 ++-- libavcodec/tta.c | 5 +++-- libavcodec/v210x.c | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 7717c4bbc6..0e792affca 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1136,7 +1136,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) switch (q->subpacket[s].cookversion) { case MONO: if (q->nb_channels != 1) { - av_log(avctx,AV_LOG_ERROR,"Container channels != 1, report sample!\n"); + av_log_ask_for_sample(avctx, "Container channels != 1.!\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"MONO\n"); @@ -1150,7 +1150,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) break; case JOINT_STEREO: if (q->nb_channels != 2) { - av_log(avctx,AV_LOG_ERROR,"Container channels != 2, report sample!\n"); + av_log_ask_for_sample(avctx, "Container channels != 2.\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"JOINT_STEREO\n"); @@ -1188,7 +1188,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) break; default: - av_log(avctx,AV_LOG_ERROR,"Unknown Cook version, report sample!\n"); + av_log_ask_for_sample(avctx, "Unknown Cook version.\n"); return -1; break; } @@ -1205,7 +1205,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) /* Try to catch some obviously faulty streams, othervise it might be exploitable */ if (q->subpacket[s].total_subbands > 53) { - av_log(avctx,AV_LOG_ERROR,"total_subbands > 53, report sample!\n"); + av_log_ask_for_sample(avctx, "total_subbands > 53\n"); return -1; } @@ -1215,7 +1215,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) } if (q->subpacket[s].subbands > 50) { - av_log(avctx,AV_LOG_ERROR,"subbands > 50, report sample!\n"); + av_log_ask_for_sample(avctx, "subbands > 50\n"); return -1; } q->subpacket[s].gains1.now = q->subpacket[s].gain_1; @@ -1226,7 +1226,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) q->num_subpackets++; s++; if (s > MAX_SUBPACKETS) { - av_log(avctx,AV_LOG_ERROR,"Too many subpackets > 5, report file!\n"); + av_log_ask_for_sample(avctx, "Too many subpackets > 5\n"); return -1; } } diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index afa9cf22fe..97330d1bb4 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -353,7 +353,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) s->flags = FLAG_KEYFRAME; if (s->flags & FLAG_SPRITE) { - av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n"); + av_log_ask_for_sample(s->avctx, "SPRITE frame found.\n"); /* FIXME header.width, height, xoffset and yoffset aren't initialized */ #if 0 s->w = header.width; @@ -370,7 +370,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) if ((s->w < 213) && (s->h >= 176)) { s->flags |= FLAG_INTERPOLATED; - av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n"); + av_log_ask_for_sample(s->avctx, "INTERPOLATION selected.\n"); } } } diff --git a/libavcodec/tta.c b/libavcodec/tta.c index fbfc59e60a..57f5818d7b 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -247,7 +247,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) if (s->is_float) { avctx->sample_fmt = AV_SAMPLE_FMT_FLT; - av_log(s->avctx, AV_LOG_ERROR, "Unsupported sample format. Please contact the developers.\n"); + av_log_ask_for_sample(s->avctx, "Unsupported sample format.\n"); return -1; } else switch(s->bps) { @@ -256,7 +256,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) // case 3: avctx->sample_fmt = AV_SAMPLE_FMT_S24; break; case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break; default: - av_log(s->avctx, AV_LOG_ERROR, "Invalid/unsupported sample format. Please contact the developers.\n"); + av_log_ask_for_sample(s->avctx, + "Invalid/unsupported sample format.\n"); return -1; } diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c index 3d8bdcf780..511548f366 100644 --- a/libavcodec/v210x.c +++ b/libavcodec/v210x.c @@ -52,7 +52,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac } if(avpkt->size > avctx->width * avctx->height * 8 / 3){ - av_log(avctx, AV_LOG_ERROR, "Probably padded data, need sample!\n"); + av_log_ask_for_sample(avctx, "Probably padded data\n"); } pic->reference= 0; From 73a51e00a74df079507d6355a4e353494ddb0385 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 21 Apr 2011 22:03:24 +0200 Subject: [PATCH 095/172] mjpeg: Detect overreads in mjpeg_decode_scan() and error out. Signed-off-by: Michael Niedermayer --- libavcodec/mjpegdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index d0fc524471..2bdd2a814b 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -797,6 +797,10 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i if (s->restart_interval && !s->restart_count) s->restart_count = s->restart_interval; + if(get_bits_count(&s->gb)>s->gb.size_in_bits){ + av_log(s->avctx, AV_LOG_ERROR, "overread %d\n", get_bits_count(&s->gb) - s->gb.size_in_bits); + return -1; + } for(i=0;i Date: Thu, 21 Apr 2011 22:04:21 +0200 Subject: [PATCH 096/172] AMV: Fix possibly exploitable crash. Reported-at: Thu, 21 Apr 2011 14:38:25 +0000 Reported-by: Dominic Chell Signed-off-by: Michael Niedermayer --- libavcodec/sp5xdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 8bcdbe41b4..dd31edaf85 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -86,7 +86,6 @@ static int sp5x_decode_frame(AVCodecContext *avctx, recoded[j++] = 0xFF; recoded[j++] = 0xD9; - avctx->flags &= ~CODEC_FLAG_EMU_EDGE; av_init_packet(&avpkt_recoded); avpkt_recoded.data = recoded; avpkt_recoded.size = j; @@ -121,6 +120,6 @@ AVCodec ff_amv_decoder = { NULL, ff_mjpeg_decode_end, sp5x_decode_frame, - CODEC_CAP_DR1, + 0, .long_name = NULL_IF_CONFIG_SMALL("AMV Video"), }; From 3283f274fdbef16d13df06661cec601e1bc01aab Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 20 Apr 2011 13:12:38 -0400 Subject: [PATCH 097/172] FATE: allow forcing thread-type when doing threaded fate runs. Signed-off-by: Ronald S. Bultje --- Makefile | 2 +- tests/fate-run.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f8e68d6c49..0849443f1d 100644 --- a/Makefile +++ b/Makefile @@ -285,7 +285,7 @@ fate: $(FATE) $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF)) @echo "TEST $(@:fate-%=%)" - $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' + $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)' fate-list: @printf '%s\n' $(sort $(FATE)) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 3a6b46b786..366145d22f 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -16,6 +16,7 @@ cmp=${6:-diff} ref=${7:-"${base}/ref/fate/${test}"} fuzz=$8 threads=${9:-1} +thread_type=${10:-3} outdir="tests/data/fate" outfile="${outdir}/${test}" @@ -49,7 +50,7 @@ run(){ } ffmpeg(){ - run ffmpeg -v 0 -threads $threads "$@" + run ffmpeg -v 0 -threads $threads -thread_type $thread_type "$@" } framecrc(){ @@ -78,7 +79,7 @@ regtest(){ cleanfiles="$cleanfiles $outfile $errfile" outfile=tests/data/regression/$2/$t errfile=tests/data/$t.$2.err - ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" + ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type" } codectest(){ From 94f7451a3a5ad61cd49da0aa9f08cefe75482007 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 20 Apr 2011 14:14:42 -0400 Subject: [PATCH 098/172] Introduce slice threads flag. Signed-off-by: Ronald S. Bultje --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 4 ++++ libavcodec/dnxhdenc.c | 1 + libavcodec/dv.c | 3 ++- libavcodec/ffv1.c | 3 ++- libavcodec/h264.c | 3 ++- libavcodec/mpeg12.c | 4 ++-- libavcodec/mpeg12enc.c | 4 ++-- libavcodec/mpeg4videoenc.c | 2 +- libavcodec/mpegvideo_enc.c | 1 + libavcodec/pthread.c | 3 ++- libavcodec/version.h | 2 +- 12 files changed, 23 insertions(+), 10 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 24ba7b143b..482b3a8c04 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-04-21 - XXXXXX - 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 diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7727ad08bf..d1377ca0f8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -676,6 +676,10 @@ typedef struct RcOverride{ * Codec supports frame-level multithreading. */ #define CODEC_CAP_FRAME_THREADS 0x1000 +/** + * Codec supports slice-based (or partition-based) multithreading. + */ +#define CODEC_CAP_SLICE_THREADS 0x2000 //The following defines may change, don't expect compatibility if you use them. #define MB_TYPE_INTRA4x4 0x0001 diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 958f9d4081..bd5f2282ae 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -869,6 +869,7 @@ AVCodec ff_dnxhd_encoder = { dnxhd_encode_init, dnxhd_encode_picture, dnxhd_encode_end, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), .priv_class = &class, diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 0b87d28e8b..5c5e7fefb1 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -1297,6 +1297,7 @@ AVCodec ff_dvvideo_encoder = { sizeof(DVVideoContext), dvvideo_init_encoder, dvvideo_encode_frame, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts = (const enum PixelFormat[]) {PIX_FMT_YUV411P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), }; @@ -1312,7 +1313,7 @@ AVCodec ff_dvvideo_decoder = { NULL, dvvideo_close, dvvideo_decode_frame, - CODEC_CAP_DR1, + CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, NULL, .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 8b46091462..bf89fae8c5 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -1795,7 +1795,7 @@ AVCodec ff_ffv1_decoder = { NULL, common_end, decode_frame, - CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, + CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/ | CODEC_CAP_SLICE_THREADS, NULL, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }; @@ -1809,6 +1809,7 @@ AVCodec ff_ffv1_encoder = { encode_init, encode_frame, common_end, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }; diff --git a/libavcodec/h264.c b/libavcodec/h264.c index dbf71a761e..cd7dccc172 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -3426,7 +3426,8 @@ AVCodec ff_h264_decoder = { NULL, ff_h264_decode_end, decode_frame, - /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY, + /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY | + CODEC_CAP_SLICE_THREADS, .flush= flush_dpb, .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .profiles = NULL_IF_CONFIG_SMALL(profiles), diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 3e9f74a696..0676f18157 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2523,7 +2523,7 @@ AVCodec ff_mpeg2video_decoder = { NULL, mpeg_decode_end, mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), @@ -2540,7 +2540,7 @@ AVCodec ff_mpegvideo_decoder = { NULL, mpeg_decode_end, mpeg_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 206e7d6bc4..5e9b2ba3b1 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -940,7 +940,7 @@ AVCodec ff_mpeg1video_encoder = { MPV_encode_end, .supported_framerates= ff_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"), }; @@ -954,6 +954,6 @@ AVCodec ff_mpeg2video_encoder = { MPV_encode_end, .supported_framerates= ff_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}, - .capabilities= CODEC_CAP_DELAY, + .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), }; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 134894c112..33ecc0ae46 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1347,6 +1347,6 @@ AVCodec ff_mpeg4_encoder = { MPV_encode_picture, MPV_encode_end, .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-4 part 2"), }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 7f9892351b..c08098506a 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3800,6 +3800,7 @@ AVCodec ff_h263p_encoder = { MPV_encode_init, MPV_encode_picture, MPV_encode_end, + .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"), }; diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index ba6e395d75..0311dcd7e9 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -877,7 +877,8 @@ static void validate_thread_parameters(AVCodecContext *avctx) avctx->active_thread_type = 0; } else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) { avctx->active_thread_type = FF_THREAD_FRAME; - } else if (avctx->thread_type & FF_THREAD_SLICE) { + } else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS && + avctx->thread_type & FF_THREAD_SLICE) { avctx->active_thread_type = FF_THREAD_SLICE; } } diff --git a/libavcodec/version.h b/libavcodec/version.h index b9c219d260..487e7a5136 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 0 +#define LIBAVCODEC_VERSION_MINOR 1 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From b4a53314f115a47567b77004e02dd317e0e29ad9 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 21 Apr 2011 19:50:19 -0400 Subject: [PATCH 099/172] APIChanges: document git revision for CODEC_CAP_SLICE_THREADS addition. --- doc/APIchanges | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 482b3a8c04..5c7b6775c4 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,7 +13,7 @@ libavutil: 2011-04-18 API changes, most recent first: -2011-04-21 - XXXXXX - lavc 53.1.0 - avcodec.h +2011-04-21 - 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 From 50f43fb0e26df6f090e88f4e09257ef5e10be0fb Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 11:24:34 +0200 Subject: [PATCH 100/172] matroskaenc: replace AVERROR_NOTSUPP with AVERROR(EINVAL) AVERROR_NOTSUPP has been dropped with the major bump. Since the signalled error denotes a configuration problem, AVERROR(EINVAL) looks an adequate replacement. Signed-off-by: Stefano Sabatini --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 5ce2a541da..5e4552a09c 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -618,7 +618,7 @@ static int mkv_write_tracks(AVFormatContext *s) put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_SUBTITLE); if (!native_id) { av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", codec->codec_id); - return AVERROR_NOTSUPP; + return AVERROR(EINVAL); } break; default: From 22180e7a5a39f8a77498fcbce54368ecc408df8f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 21 Apr 2011 11:48:44 +0200 Subject: [PATCH 101/172] error: remove symbols which were deprecated before the big bump The removal was not applied when merging the Libav patches, because there was still code referencing the symbols. Signed-off-by: Stefano Sabatini --- libavutil/error.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libavutil/error.h b/libavutil/error.h index f6a5942060..47d366ebbc 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -37,15 +37,6 @@ #define AVUNERROR(e) (e) #endif -#define AVERROR_IO AVERROR(EIO) ///< I/O error -#define AVERROR_NOENT AVERROR(ENOENT) ///< No such file or directory -#define AVERROR_NOFMT AVERROR(EILSEQ) ///< Unknown format -#define AVERROR_NOMEM AVERROR(ENOMEM) ///< Not enough memory -#define AVERROR_NOTSUPP AVERROR(ENOSYS) ///< Operation not supported -#define AVERROR_UNKNOWN AVERROR(EINVAL) ///< Unknown error - - - #define AVERROR_BSF_NOT_FOUND (-MKTAG(0xF8,'B','S','F')) ///< Bitstream filter not found #define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found #define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found From 9978ed7d6c07ef12220b57b5f9f8e48ab363141e Mon Sep 17 00:00:00 2001 From: Young Han Lee Date: Fri, 22 Apr 2011 21:39:56 +0900 Subject: [PATCH 102/172] aacdec: indentation cosmetics Signed-off-by: Diego Biurrun --- libavcodec/aacdec.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index c9761a1aef..3160c66d44 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -180,9 +180,8 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id) * @return Returns error status. 0 - OK, !0 - error */ static av_cold int che_configure(AACContext *ac, - enum ChannelPosition che_pos[4][MAX_ELEM_ID], - int type, int id, - int *channels) + enum ChannelPosition che_pos[4][MAX_ELEM_ID], + int type, int id, int *channels) { if (che_pos[type][id]) { if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) @@ -212,9 +211,9 @@ static av_cold int che_configure(AACContext *ac, * @return Returns error status. 0 - OK, !0 - error */ static av_cold int output_configure(AACContext *ac, - enum ChannelPosition che_pos[4][MAX_ELEM_ID], - enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], - int channel_config, enum OCStatus oc_type) + enum ChannelPosition che_pos[4][MAX_ELEM_ID], + enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], + int channel_config, enum OCStatus oc_type) { AVCodecContext *avctx = ac->avctx; int i, type, channels = 0, ret; @@ -231,7 +230,7 @@ static av_cold int output_configure(AACContext *ac, return ret; } - memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); + memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); avctx->channel_layout = aac_channel_layout[channel_config - 1]; } else { @@ -346,8 +345,8 @@ static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, * @return Returns error status. 0 - OK, !0 - error */ static av_cold int set_default_channel_config(AVCodecContext *avctx, - enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], - int channel_config) + enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], + int channel_config) { if (channel_config < 1 || channel_config > 7) { av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n", @@ -1235,7 +1234,7 @@ static av_always_inline float flt16_trunc(float pf) static av_always_inline void predict(PredictorState *ps, float *coef, float sf_scale, float inv_sf_scale, - int output_enable) + int output_enable) { const float a = 0.953125; // 61.0 / 64 const float alpha = 0.90625; // 29.0 / 32 From cc0ac0d2cb957c21e1bbfb90e07cedbcab1ee960 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 22 Apr 2011 16:00:00 +0200 Subject: [PATCH 103/172] rv10: set flags, Fixes Ticket90 Signed-off-by: Michael Niedermayer --- libavcodec/rv10.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index e6e9afafb0..8185b75546 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -656,6 +656,8 @@ static int rv10_decode_frame(AVCodecContext *avctx, const uint8_t *slices_hdr = NULL; av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size); + s->flags = avctx->flags; + s->flags2 = avctx->flags2; /* no supplementary picture */ if (buf_size == 0) { From 07f45bc9887daa0cf760de46f8ee098ca2563725 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 22 Apr 2011 18:45:47 +0200 Subject: [PATCH 104/172] Support Canopus SD50 with fourcc "CDV5". Fixes ticket #93. --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 5a40d9a339..e884780b76 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -107,6 +107,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') }, { CODEC_ID_DVVIDEO, MKTAG('c', 'd', 'v', 'c') }, /* Canopus DV */ { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', 'H') }, /* Canopus DV */ + { CODEC_ID_DVVIDEO, MKTAG('C', 'D', 'V', '5') }, /* Canopus DV */ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', ' ') }, { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 's') }, { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', '1') }, From 3c483620c9a92c040b3f747e11b048e145653ce5 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 22 Apr 2011 18:49:44 +0200 Subject: [PATCH 105/172] Cosmetics: Rename variable daemon as run_as_daemon. daemon() is defined in unistd.h for BSD and Cygwin. --- ffmpeg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index a5b51b790a..8749907358 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -233,7 +233,7 @@ static int audio_volume = 256; static int exit_on_error = 0; static int using_stdin = 0; static int verbose = 1; -static int daemon = 0; +static int run_as_daemon = 0; static int thread_count= 1; static int q_pressed = 0; static int64_t video_size = 0; @@ -439,7 +439,7 @@ static void term_exit(void) { av_log(NULL, AV_LOG_QUIET, ""); #if HAVE_TERMIOS_H - if(!daemon) + if(!run_as_daemon) tcsetattr (0, TCSANOW, &oldtty); #endif } @@ -457,7 +457,7 @@ sigterm_handler(int sig) static void term_init(void) { #if HAVE_TERMIOS_H - if(!daemon){ + if(!run_as_daemon){ struct termios tty; tcgetattr (0, &tty); @@ -494,7 +494,7 @@ static int read_key(void) struct timeval tv; fd_set rfds; - if(daemon) + if(run_as_daemon) return -1; FD_ZERO(&rfds); @@ -4414,7 +4414,7 @@ int main(int argc, char **argv) av_log_set_flags(AV_LOG_SKIP_REPEATED); if(argc>1 && !strcmp(argv[1], "-d")){ - daemon=1; + run_as_daemon=1; verbose=-1; av_log_set_callback(log_callback_null); argc--; From a08a59b736621062a1a7bd931fc1c71904caee34 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 22 Apr 2011 19:24:17 +0200 Subject: [PATCH 106/172] FLV muxing is supported. --- doc/general.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/general.texi b/doc/general.texi index 303b5fbba6..27937860ae 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -96,7 +96,7 @@ library: @tab Only embedded audio is decoded. @item FLI/FLC/FLX animation @tab @tab X @tab .fli/.flc files -@item Flash Video (FLV) @tab @tab X +@item Flash Video (FLV) @tab X @tab X @tab Macromedia Flash video files @item framecrc testing format @tab X @tab @item FunCom ISS @tab @tab X From b2832c3904211f2e95f49059d15b94dfab55964a Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 22 Apr 2011 19:46:54 +0200 Subject: [PATCH 107/172] vqavideo: We no longer need to ask for version 1 samples. --- libavcodec/vqavideo.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index 40004a0028..a842ac7d70 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -464,8 +464,6 @@ static void vqa_decode_chunk(VqaContext *s) switch (s->vqa_version) { case 1: -/* still need sample media for this case (only one game, "Legend of - * Kyrandia III : Malcolm's Revenge", is known to use this version) */ lobyte = s->decode_buffer[lobytes * 2]; hibyte = s->decode_buffer[(lobytes * 2) + 1]; vector_index = ((hibyte << 8) | lobyte) >> 3; From 03ac7991286c583c73c8c44c71aeba1265c61cba Mon Sep 17 00:00:00 2001 From: Robert Leatherwood Date: Fri, 22 Apr 2011 20:10:26 +0200 Subject: [PATCH 108/172] Rm duplicated define for OPT_STR. --- libavcodec/libx264.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index c1e60e6d5f..acd13668d7 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -190,15 +190,6 @@ static void check_default_settings(AVCodecContext *avctx) } } -#define OPT_STR(opt, param) \ - do { \ - if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ - av_log(avctx, AV_LOG_ERROR, \ - "bad value for '%s': '%s'\n", opt, param); \ - return -1; \ - } \ - } while (0); \ - #define OPT_STR(opt, param) \ do { \ if (param && x264_param_parse(&x4->params, opt, param) < 0) { \ From 44f566b79afcbbb152ec21db667ea3d2f42e8f8d Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 22 Apr 2011 19:30:25 +0200 Subject: [PATCH 109/172] Make av_log_ask_for_sample() accept a variable number of arguments. --- libavcodec/avcodec.h | 2 +- libavcodec/utils.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index d1377ca0f8..14f00bb5d0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -4116,7 +4116,7 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample); * a pointer to an AVClass struct * @param[in] msg string containing an optional message, or NULL if no message */ -void av_log_ask_for_sample(void *avc, const char *msg); +void av_log_ask_for_sample(void *avc, const char *msg, ...); /** * Register the hardware accelerator hwaccel. diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 744e0ada87..d60e236952 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1133,13 +1133,19 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample) av_log(avc, AV_LOG_WARNING, "\n"); } -void av_log_ask_for_sample(void *avc, const char *msg) +void av_log_ask_for_sample(void *avc, const char *msg, ...) { + va_list argument_list; + + va_start(argument_list, msg); + if (msg) - av_log(avc, AV_LOG_WARNING, "%s ", msg); + av_vlog(avc, AV_LOG_WARNING, msg, argument_list); av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample " "of this file to ftp://upload.libav.org/incoming/ " "and contact the libav-devel mailing list.\n"); + + va_end(argument_list); } static AVHWAccel *first_hwaccel = NULL; From d9dee728b8c50fb6dbff3701e1abcb2eac5895b3 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 22 Apr 2011 19:41:59 +0200 Subject: [PATCH 110/172] Use av_log_ask_for_sample() to request samples from users. --- libavcodec/atrac3.c | 2 +- libavcodec/cook.c | 4 +++- libavcodec/loco.c | 2 +- libavcodec/wnv1.c | 6 ++++-- libavformat/oma.c | 3 ++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 563352094d..78df5f1fb3 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -186,7 +186,7 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ obuf[i] = c ^ buf[i]; if (off) - av_log(NULL,AV_LOG_DEBUG,"Offset of %d not handled, post sample on ffmpeg-dev.\n",off); + av_log_ask_for_sample(NULL, "Offset of %d not handled.\n", off); return off; } diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 0e792affca..282ca1029d 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1268,7 +1268,9 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) /* Try to catch some obviously faulty streams, othervise it might be exploitable */ if ((q->samples_per_channel == 256) || (q->samples_per_channel == 512) || (q->samples_per_channel == 1024)) { } else { - av_log(avctx,AV_LOG_ERROR,"unknown amount of samples_per_channel = %d, report sample!\n",q->samples_per_channel); + av_log_ask_for_sample(avctx, + "unknown amount of samples_per_channel = %d\n", + q->samples_per_channel); return -1; } diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 0733d09e49..32b1bfc9b1 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -248,7 +248,7 @@ static av_cold int decode_init(AVCodecContext *avctx){ break; default: l->lossy = AV_RL32(avctx->extradata + 8); - av_log(avctx, AV_LOG_INFO, "This is LOCO codec version %i, please upload file for study\n", version); + av_log_ask_for_sample(avctx, "This is LOCO codec version %i.\n", version); } l->mode = AV_RL32(avctx->extradata + 4); diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index 7c0a537082..65ad9cdd12 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -96,11 +96,13 @@ static int decode_frame(AVCodecContext *avctx, else { l->shift = 8 - (buf[2] >> 4); if (l->shift > 4) { - av_log(avctx, AV_LOG_ERROR, "Unknown WNV1 frame header value %i, please upload file for study\n", buf[2] >> 4); + av_log_ask_for_sample(avctx, "Unknown WNV1 frame header value %i\n", + buf[2] >> 4); l->shift = 4; } if (l->shift < 1) { - av_log(avctx, AV_LOG_ERROR, "Unknown WNV1 frame header value %i, please upload file for study\n", buf[2] >> 4); + av_log_ask_for_sample(avctx, "Unknown WNV1 frame header value %i\n", + buf[2] >> 4); l->shift = 1; } } diff --git a/libavformat/oma.c b/libavformat/oma.c index ba8901dfdb..6dd56cf702 100644 --- a/libavformat/oma.c +++ b/libavformat/oma.c @@ -107,7 +107,8 @@ static int oma_read_header(AVFormatContext *s, case OMA_CODECID_ATRAC3: samplerate = srate_tab[(codec_params >> 13) & 7]*100; if (samplerate != 44100) - av_log(s, AV_LOG_ERROR, "Unsupported sample rate, send sample file to developers: %d\n", samplerate); + av_log_ask_for_sample(s, "Unsupported sample rate: %d\n", + samplerate); framesize = (codec_params & 0x3FF) * 8; jsflag = (codec_params >> 17) & 1; /* get stereo coding mode, 1 for joint-stereo */ From d5c5a1c7e2959a5174522b5ac1d73d5095b8c5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 22 Apr 2011 00:45:06 +0300 Subject: [PATCH 111/172] doc: Mention that DragonFly BSD requires __BSD_VISIBLE set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setting this should fix the FATE build failure on DragonFly BSD, since inet_aton only is visible if __BSD_VISIBLE is set. Alternatively, a line defining __BSD_VISIBLE=1 could be added at the top of os_support.c. For FreeBSD, similar lines are required in libavdevice/bktr.c and libavdevice/oss_audio.c, too. Signed-off-by: Martin Storsjö --- doc/general.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index 423402ca4e..edd5e60cc3 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -784,9 +784,9 @@ to configure. BSD make will not build Libav, you need to install and use GNU Make (@file{gmake}). -@subsubsection FreeBSD +@subsubsection FreeBSD, DragonFly BSD -FreeBSD will not compile out-of-the-box due to broken system headers. +These systems will not compile out-of-the-box due to broken system headers. Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work around the problem. This may have unexpected sideeffects, so use it at your own risk. If you care about FreeBSD, please make an attempt at From 6e4f70a8de69884ce0caa8735d7a88915b4391d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 23 Jan 2011 01:31:41 +0200 Subject: [PATCH 112/172] Add a protocol handler for AES CBC decryption with PKCS7 padding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can later be extended to support other AES bit sizes, encryption, other crypto algorithms, reading the key from a URL, etc. In order to use it, the key and initialization vector has to be passed via AVOptions. Since such options can't be passed to protocols from the command line, the protocol is currently only for libavformat internal use. Signed-off-by: Martin Storsjö --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/crypto.c | 170 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 libavformat/crypto.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 5e029ed96b..e2e3982125 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -312,6 +312,7 @@ OBJS+= avio.o aviobuf.o OBJS-$(CONFIG_APPLEHTTP_PROTOCOL) += applehttpproto.o OBJS-$(CONFIG_CONCAT_PROTOCOL) += concat.o +OBJS-$(CONFIG_CRYPTO_PROTOCOL) += crypto.o OBJS-$(CONFIG_FILE_PROTOCOL) += file.o OBJS-$(CONFIG_GOPHER_PROTOCOL) += gopher.o OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 931947d60a..f1c3d3b768 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -235,6 +235,7 @@ void av_register_all(void) /* protocols */ REGISTER_PROTOCOL (APPLEHTTP, applehttp); REGISTER_PROTOCOL (CONCAT, concat); + REGISTER_PROTOCOL (CRYPTO, crypto); REGISTER_PROTOCOL (FILE, file); REGISTER_PROTOCOL (GOPHER, gopher); REGISTER_PROTOCOL (HTTP, http); diff --git a/libavformat/crypto.c b/libavformat/crypto.c new file mode 100644 index 0000000000..ea6012ad09 --- /dev/null +++ b/libavformat/crypto.c @@ -0,0 +1,170 @@ +/* + * Decryption protocol handler + * Copyright (c) 2011 Martin Storsjo + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "libavutil/aes.h" +#include "libavutil/avstring.h" +#include "libavutil/opt.h" +#include "internal.h" +#include "url.h" + +#define MAX_BUFFER_BLOCKS 150 +#define BLOCKSIZE 16 + +typedef struct { + const AVClass *class; + URLContext *hd; + uint8_t inbuffer [BLOCKSIZE*MAX_BUFFER_BLOCKS], + outbuffer[BLOCKSIZE*MAX_BUFFER_BLOCKS]; + uint8_t *outptr; + int indata, indata_used, outdata; + int eof; + uint8_t *key; + int keylen; + uint8_t *iv; + int ivlen; + struct AVAES *aes; +} CryptoContext; + +#define OFFSET(x) offsetof(CryptoContext, x) +static const AVOption options[] = { + {"key", "AES decryption key", OFFSET(key), FF_OPT_TYPE_BINARY }, + {"iv", "AES decryption initialization vector", OFFSET(iv), FF_OPT_TYPE_BINARY }, + { NULL } +}; + +static const AVClass crypto_class = { + "crypto", av_default_item_name, options, LIBAVUTIL_VERSION_INT +}; + +static int crypto_open(URLContext *h, const char *uri, int flags) +{ + const char *nested_url; + int ret; + CryptoContext *c = h->priv_data; + + if (!av_strstart(uri, "crypto+", &nested_url) && + !av_strstart(uri, "crypto:", &nested_url)) { + av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri); + ret = AVERROR(EINVAL); + goto err; + } + + if (c->keylen < BLOCKSIZE || c->ivlen < BLOCKSIZE) { + av_log(h, AV_LOG_ERROR, "Key or IV not set\n"); + ret = AVERROR(EINVAL); + goto err; + } + if (flags & AVIO_FLAG_WRITE) { + av_log(h, AV_LOG_ERROR, "Only decryption is supported currently\n"); + ret = AVERROR(ENOSYS); + goto err; + } + if ((ret = ffurl_open(&c->hd, nested_url, AVIO_FLAG_READ)) < 0) { + av_log(h, AV_LOG_ERROR, "Unable to open input\n"); + goto err; + } + c->aes = av_mallocz(av_aes_size); + if (!c->aes) { + ret = AVERROR(ENOMEM); + goto err; + } + + av_aes_init(c->aes, c->key, 128, 1); + + h->is_streamed = 1; + + return 0; +err: + av_free(c->key); + av_free(c->iv); + return ret; +} + +static int crypto_read(URLContext *h, uint8_t *buf, int size) +{ + CryptoContext *c = h->priv_data; + int blocks; +retry: + if (c->outdata > 0) { + size = FFMIN(size, c->outdata); + memcpy(buf, c->outptr, size); + c->outptr += size; + c->outdata -= size; + return size; + } + // We avoid using the last block until we've found EOF, + // since we'll remove PKCS7 padding at the end. So make + // sure we've got at least 2 blocks, so we can decrypt + // at least one. + while (c->indata - c->indata_used < 2*BLOCKSIZE) { + int n = ffurl_read(c->hd, c->inbuffer + c->indata, + sizeof(c->inbuffer) - c->indata); + if (n <= 0) { + c->eof = 1; + break; + } + c->indata += n; + } + blocks = (c->indata - c->indata_used) / BLOCKSIZE; + if (!blocks) + return AVERROR_EOF; + if (!c->eof) + blocks--; + av_aes_crypt(c->aes, c->outbuffer, c->inbuffer + c->indata_used, blocks, + c->iv, 1); + c->outdata = BLOCKSIZE * blocks; + c->outptr = c->outbuffer; + c->indata_used += BLOCKSIZE * blocks; + if (c->indata_used >= sizeof(c->inbuffer)/2) { + memmove(c->inbuffer, c->inbuffer + c->indata_used, + c->indata - c->indata_used); + c->indata -= c->indata_used; + c->indata_used = 0; + } + if (c->eof) { + // Remove PKCS7 padding at the end + int padding = c->outbuffer[c->outdata - 1]; + c->outdata -= padding; + } + goto retry; +} + +static int crypto_close(URLContext *h) +{ + CryptoContext *c = h->priv_data; + if (c->hd) + ffurl_close(c->hd); + av_free(c->aes); + av_free(c->key); + av_free(c->iv); + return 0; +} + +URLProtocol ff_crypto_protocol = { + .name = "crypto", + .url_open = crypto_open, + .url_read = crypto_read, + .url_close = crypto_close, + .priv_data_size = sizeof(CryptoContext), + .priv_data_class = &crypto_class, + .flags = URL_PROTOCOL_FLAG_NESTED_SCHEME, +}; From 84465f2180308a3e998089517e76586563fd6162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 23 Jan 2011 23:42:18 +0200 Subject: [PATCH 113/172] applehttp: Handle AES-128 encrypted streams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should hopefully fix roundup issue 2586. This commit only implements it in the demuxer, not in the protocol handler. If desired, some of the code could be refactored to be shared by both implementations. Signed-off-by: Martin Storsjö --- libavformat/applehttp.c | 108 ++++++++++++++++++++++++++++++++++++++-- libavformat/version.h | 2 +- 2 files changed, 106 insertions(+), 4 deletions(-) diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 90b86a8733..2e0e8a1b3a 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -27,6 +27,8 @@ #define _XOPEN_SOURCE 600 #include "libavutil/avstring.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" #include "avformat.h" #include "internal.h" #include @@ -47,9 +49,17 @@ * one anonymous toplevel variant for this, to maintain the structure. */ +enum KeyType { + KEY_NONE, + KEY_AES_128, +}; + struct segment { int duration; char url[MAX_URL_SIZE]; + char key[MAX_URL_SIZE]; + enum KeyType key_type; + uint8_t iv[16]; }; /* @@ -77,6 +87,9 @@ struct variant { int needed, cur_needed; int cur_seq_no; int64_t last_load_time; + + char key_url[MAX_URL_SIZE]; + uint8_t key[16]; }; typedef struct AppleHTTPContext { @@ -160,10 +173,35 @@ static void handle_variant_args(struct variant_info *info, const char *key, } } +struct key_info { + char uri[MAX_URL_SIZE]; + char method[10]; + char iv[35]; +}; + +static void handle_key_args(struct key_info *info, const char *key, + int key_len, char **dest, int *dest_len) +{ + if (!strncmp(key, "METHOD=", key_len)) { + *dest = info->method; + *dest_len = sizeof(info->method); + } else if (!strncmp(key, "URI=", key_len)) { + *dest = info->uri; + *dest_len = sizeof(info->uri); + } else if (!strncmp(key, "IV=", key_len)) { + *dest = info->iv; + *dest_len = sizeof(info->iv); + } +} + static int parse_playlist(AppleHTTPContext *c, const char *url, struct variant *var, AVIOContext *in) { int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0; + enum KeyType key_type = KEY_NONE; + uint8_t iv[16] = ""; + int has_iv = 0; + char key[MAX_URL_SIZE]; char line[1024]; const char *ptr; int close_in = 0; @@ -192,6 +230,19 @@ static int parse_playlist(AppleHTTPContext *c, const char *url, ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args, &info); bandwidth = atoi(info.bandwidth); + } else if (av_strstart(line, "#EXT-X-KEY:", &ptr)) { + struct key_info info = {{0}}; + ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_key_args, + &info); + key_type = KEY_NONE; + has_iv = 0; + if (!strcmp(info.method, "AES-128")) + key_type = KEY_AES_128; + if (!strncmp(info.iv, "0x", 2) || !strncmp(info.iv, "0X", 2)) { + ff_hex_to_data(iv, info.iv + 2); + has_iv = 1; + } + av_strlcpy(key, info.uri, sizeof(key)); } else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) { if (!var) { var = new_variant(c, 0, url, NULL); @@ -242,6 +293,15 @@ static int parse_playlist(AppleHTTPContext *c, const char *url, goto fail; } seg->duration = duration; + seg->key_type = key_type; + if (has_iv) { + memcpy(seg->iv, iv, sizeof(iv)); + } else { + int seq = var->start_seq_no + var->n_segments; + memset(seg->iv, 0, sizeof(seg->iv)); + AV_WB32(seg->iv + 12, seq); + } + ff_make_absolute_url(seg->key, sizeof(seg->key), url, key); ff_make_absolute_url(seg->url, sizeof(seg->url), url, line); dynarray_add(&var->segments, &var->n_segments, seg); is_segment = 0; @@ -257,6 +317,50 @@ fail: return ret; } +static int open_input(struct variant *var) +{ + struct segment *seg = var->segments[var->cur_seq_no - var->start_seq_no]; + if (seg->key_type == KEY_NONE) { + return ffurl_open(&var->input, seg->url, AVIO_FLAG_READ); + } else if (seg->key_type == KEY_AES_128) { + char iv[33], key[33], url[MAX_URL_SIZE]; + int ret; + if (strcmp(seg->key, var->key_url)) { + URLContext *uc; + if (ffurl_open(&uc, seg->key, AVIO_FLAG_READ) == 0) { + if (ffurl_read_complete(uc, var->key, sizeof(var->key)) + != sizeof(var->key)) { + av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n", + seg->key); + } + ffurl_close(uc); + } else { + av_log(NULL, AV_LOG_ERROR, "Unable to open key file %s\n", + seg->key); + } + av_strlcpy(var->key_url, seg->key, sizeof(var->key_url)); + } + ff_data_to_hex(iv, seg->iv, sizeof(seg->iv), 0); + ff_data_to_hex(key, var->key, sizeof(var->key), 0); + iv[32] = key[32] = '\0'; + if (strstr(seg->url, "://")) + snprintf(url, sizeof(url), "crypto+%s", seg->url); + else + snprintf(url, sizeof(url), "crypto:%s", seg->url); + if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ)) < 0) + return ret; + av_set_string3(var->input->priv_data, "key", key, 0, NULL); + av_set_string3(var->input->priv_data, "iv", iv, 0, NULL); + if ((ret = ffurl_connect(var->input)) < 0) { + ffurl_close(var->input); + var->input = NULL; + return ret; + } + return 0; + } + return AVERROR(ENOSYS); +} + static int read_data(void *opaque, uint8_t *buf, int buf_size) { struct variant *v = opaque; @@ -291,9 +395,7 @@ reload: goto reload; } - ret = ffurl_open(&v->input, - v->segments[v->cur_seq_no - v->start_seq_no]->url, - AVIO_FLAG_READ); + ret = open_input(v); if (ret < 0) return ret; } diff --git a/libavformat/version.h b/libavformat/version.h index 04c5d73f50..9041f92626 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -25,7 +25,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MINOR 0 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MICRO 2 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From 6ffd7eddb832a21f51661038620ef655640ee83f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Fri, 22 Apr 2011 19:24:17 +0200 Subject: [PATCH 114/172] doc: FLV muxing is supported. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- doc/general.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/general.texi b/doc/general.texi index edd5e60cc3..303159eba7 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -96,7 +96,7 @@ library: @tab Only embedded audio is decoded. @item FLI/FLC/FLX animation @tab @tab X @tab .fli/.flc files -@item Flash Video (FLV) @tab @tab X +@item Flash Video (FLV) @tab X @tab X @tab Macromedia Flash video files @item framecrc testing format @tab X @tab @item FunCom ISS @tab @tab X From 15919ee48f507a4ca17147e7247f5cb68f752c2c Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Fri, 22 Apr 2011 17:59:55 -0400 Subject: [PATCH 115/172] bswap: use native types for av_bwap16(). This prevents a call to bytestream_get_be16() using a movzwl both before and after the ror instruction, which is obviously inefficient. Arm uses the same trick also. Sintel decoding goes from (avg+SD) 9.856 +/- 0.003 to 9.797 +/- 0.003 sec. Signed-off-by: Ronald S. Bultje --- libavutil/x86/bswap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/x86/bswap.h b/libavutil/x86/bswap.h index 28e3fecb1b..b60d9ccd6c 100644 --- a/libavutil/x86/bswap.h +++ b/libavutil/x86/bswap.h @@ -29,9 +29,9 @@ #include "libavutil/attributes.h" #define av_bswap16 av_bswap16 -static av_always_inline av_const uint16_t av_bswap16(uint16_t x) +static av_always_inline av_const unsigned av_bswap16(unsigned x) { - __asm__("rorw $8, %0" : "+r"(x)); + __asm__("rorw $8, %w0" : "+r"(x)); return x; } From 3583d7cffe5173cc02c5476451800efdc767ce15 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 20 Apr 2011 17:25:47 +0000 Subject: [PATCH 116/172] Fix mov debug (u)int64_t format strings. --- libavformat/mov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 76dc8a13af..65fcf19870 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -588,7 +588,7 @@ static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) { c->fragment.moof_offset = avio_tell(pb) - 8; - av_dlog(c->fc, "moof offset %llx\n", c->fragment.moof_offset); + av_dlog(c->fc, "moof offset %"PRIx64"\n", c->fragment.moof_offset); return mov_read_default(c, pb, atom); } @@ -2367,7 +2367,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_ERROR, "moov atom not found\n"); return -1; } - av_dlog(mov->fc, "on_parse_exit_offset=%lld\n", avio_tell(pb)); + av_dlog(mov->fc, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb)); if (pb->seekable && mov->chapter_track > 0) mov_read_chapters(s); @@ -2416,7 +2416,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || s->pb->eof_reached) return AVERROR_EOF; - av_dlog(s, "read fragments, offset 0x%llx\n", avio_tell(s->pb)); + av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); goto retry; } sc = st->priv_data; From 785c4418289e5aace9823823a8d19974e40d4b64 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 20 Apr 2011 17:47:28 +0000 Subject: [PATCH 117/172] Add some debug log messages to AAC extradata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Wed, Apr 20, 2011 at 11:39 AM, Justin Ruggles wrote: > On 04/20/2011 02:26 PM, Alex Converse wrote: > >> --- >>  libavcodec/aacdec.c |   10 +++++++++- >>  1 files changed, 9 insertions(+), 1 deletions(-) >> >> >> >> 0002-Add-some-Debug-log-messages-to-AAC-extradata.patch >> >> >> diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c >> index c9761a1..3ec274f 100644 >> --- a/libavcodec/aacdec.c >> +++ b/libavcodec/aacdec.c >> @@ -79,7 +79,6 @@ >>             Parametric Stereo. >>   */ >> >> - >>  #include "avcodec.h" >>  #include "internal.h" >>  #include "get_bits.h" > > > stray whitespace change > oops, fixed >From 94e8d0eea77480630f84368c97646cabc0f50628 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 20 Apr 2011 11:23:34 -0700 Subject: [PATCH] Add some debug log messages to AAC extradata MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1" This is a multi-part message in MIME format. --------------1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit --- libavcodec/aacdec.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 3160c66d44..0c6312fb01 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -463,6 +463,11 @@ static int decode_audio_specific_config(AACContext *ac, GetBitContext gb; int i; + av_dlog(avctx, "extradata size %d\n", avctx->extradata_size); + for (i = 0; i < avctx->extradata_size; i++) + av_dlog(avctx, "%02x ", avctx->extradata[i]); + av_dlog(avctx, "\n"); + init_get_bits(&gb, data, data_size * 8); if ((i = ff_mpeg4audio_get_config(m4ac, data, data_size)) < 0) @@ -489,6 +494,10 @@ static int decode_audio_specific_config(AACContext *ac, return -1; } + av_dlog(avctx, "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n", + m4ac->object_type, m4ac->chan_config, m4ac->sampling_index, + m4ac->sample_rate, m4ac->sbr, m4ac->ps); + return get_bits_count(&gb); } From cfc2a0cf848e71fcec0861a73b26c2c96a201357 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 21 Apr 2011 18:39:04 +0000 Subject: [PATCH 118/172] Remove RDFT dependency from AAC decoder. $subj >From 557176d961c70604c2a96d81aff4bd6faa670d8a Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 21 Apr 2011 12:11:42 -0700 Subject: [PATCH] Remove RDFT dependency from AAC decoder. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1" This is a multi-part message in MIME format. --------------1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit It was used for an old implementation of the SBR filterbank. ./configure --disable-everything --disable-ffplay --enable-decoder=aac works. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index dd44ba4739..c01c551cf5 100755 --- a/configure +++ b/configure @@ -1237,7 +1237,7 @@ mdct_select="fft" rdft_select="fft" # decoders / encoders / hardware accelerators -aac_decoder_select="mdct rdft sinewin" +aac_decoder_select="mdct sinewin" aac_encoder_select="mdct sinewin" aac_latm_decoder_select="aac_decoder aac_latm_parser" ac3_decoder_select="mdct ac3dsp ac3_parser" From 4b5c21757bf614b09c94cb5aef5f89ba885b0bd9 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 23 Apr 2011 10:06:39 +0200 Subject: [PATCH 119/172] Fix compilation after version bump. --- libavcodec/libcelt_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libcelt_dec.c b/libavcodec/libcelt_dec.c index 3e52ab572e..f0e908b39c 100644 --- a/libavcodec/libcelt_dec.c +++ b/libavcodec/libcelt_dec.c @@ -43,7 +43,7 @@ static int ff_celt_error_to_averror(int err) case CELT_UNIMPLEMENTED: return AVERROR(ENOTSUP); case CELT_INVALID_STATE: return AVERROR(ENOTRECOVERABLE); case CELT_ALLOC_FAIL: return AVERROR(ENOMEM); - default: return AVERROR_UNKNOWN; + default: return AVERROR(EINVAL); } } From e499187f2eed5a1e488b0da589dbe89f1c5dc480 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 23 Apr 2011 10:09:11 +0200 Subject: [PATCH 120/172] Fix compilation with libcelt on Apple OS X. Fixes ticket #97. --- libavcodec/libcelt_dec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/libcelt_dec.c b/libavcodec/libcelt_dec.c index f0e908b39c..6f3965401c 100644 --- a/libavcodec/libcelt_dec.c +++ b/libavcodec/libcelt_dec.c @@ -41,7 +41,9 @@ static int ff_celt_error_to_averror(int err) case CELT_INTERNAL_ERROR: return AVERROR(EFAULT); case CELT_CORRUPTED_DATA: return AVERROR_INVALIDDATA; case CELT_UNIMPLEMENTED: return AVERROR(ENOTSUP); +#ifdef ENOTRECOVERABLE case CELT_INVALID_STATE: return AVERROR(ENOTRECOVERABLE); +#endif case CELT_ALLOC_FAIL: return AVERROR(ENOMEM); default: return AVERROR(EINVAL); } From 2a2146aac0e1c7649d674905b6a6645b722aef2e Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 23 Apr 2011 10:19:21 +0200 Subject: [PATCH 121/172] Extend unknown CAF chunk warning message: Print size. --- libavformat/cafdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 16c4674589..43d466f8c4 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -259,8 +259,8 @@ static int read_header(AVFormatContext *s, default: #define _(x) ((x) >= ' ' ? (x) : ' ') - av_log(s, AV_LOG_WARNING, "skipping CAF chunk: %08X (%c%c%c%c)\n", - tag, _(tag>>24), _((tag>>16)&0xFF), _((tag>>8)&0xFF), _(tag&0xFF)); + av_log(s, AV_LOG_WARNING, "skipping CAF chunk: %08X (%c%c%c%c), size %"PRId64"\n", + tag, _(tag>>24), _((tag>>16)&0xFF), _((tag>>8)&0xFF), _(tag&0xFF), size); #undef _ case MKBETAG('f','r','e','e'): if (size < 0) From 8bb5d1c39c9646022720ec93ef8a1b49bf558790 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 23 Apr 2011 10:30:18 +0200 Subject: [PATCH 122/172] Support channel layout when demuxing caf files. --- libavformat/caf.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ libavformat/caf.h | 3 +++ libavformat/cafdec.c | 6 +++++ 3 files changed, 67 insertions(+) diff --git a/libavformat/caf.c b/libavformat/caf.c index 96fb8474d2..d661406657 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -56,3 +56,61 @@ const AVCodecTag ff_codec_caf_tags[] = { /*{ MPEG4TwinVQ MKBETAG('t','w','v','q') },*/ { CODEC_ID_NONE, 0 }, }; + +typedef struct CafChannelLayout { + int64_t channel_layout; + uint32_t layout_tag; +} CafChannelLayout; + +static const CafChannelLayout caf_channel_layout[] = { + { AV_CH_LAYOUT_MONO, (100<<16) | 1}, //< kCAFChannelLayoutTag_Mono + { AV_CH_LAYOUT_STEREO, (101<<16) | 2}, //< kCAFChannelLayoutTag_Stereo + { AV_CH_LAYOUT_STEREO, (102<<16) | 2}, //< kCAFChannelLayoutTag_StereoHeadphones + { AV_CH_LAYOUT_2_1, (131<<16) | 3}, //< kCAFChannelLayoutTag_ITU_2_1 + { AV_CH_LAYOUT_2_2, (132<<16) | 4}, //< kCAFChannelLayoutTag_ITU_2_2 + { AV_CH_LAYOUT_QUAD, (108<<16) | 4}, //< kCAFChannelLayoutTag_Quadraphonic + { AV_CH_LAYOUT_SURROUND, (113<<16) | 3}, //< kCAFChannelLayoutTag_MPEG_3_0_A + { AV_CH_LAYOUT_4POINT0, (115<<16) | 4}, //< kCAFChannelLayoutTag_MPEG_4_0_A + { AV_CH_LAYOUT_5POINT0_BACK, (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A + { AV_CH_LAYOUT_5POINT0, (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A + { AV_CH_LAYOUT_5POINT1_BACK, (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A + { AV_CH_LAYOUT_5POINT1, (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A + { AV_CH_LAYOUT_7POINT1, (128<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_C + { AV_CH_LAYOUT_7POINT1_WIDE, (126<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_A + { AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY, (133<<16) | 3}, //< kCAFChannelLayoutTag_DVD_4 + { AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY, (134<<16) | 4}, //< kCAFChannelLayoutTag_DVD_5 + { AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY, (135<<16) | 4}, //< kCAFChannelLayoutTag_DVD_6 + { AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY, (136<<16) | 4}, //< kCAFChannelLayoutTag_DVD_10 + { AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY, (137<<16) | 5}, //< kCAFChannelLayoutTag_DVD_11 + { 0, 0}, +}; + +void ff_read_chan_chunk(AVFormatContext *s, int64_t size, AVCodecContext *codec) +{ + uint32_t layout_tag; + AVIOContext *pb = s->pb; + const CafChannelLayout *caf_layout = caf_channel_layout; + if (size != 12) { + // Channel descriptions not implemented + av_log_ask_for_sample(s, "Unimplemented channel layout."); + avio_skip(pb, size); + return; + } + layout_tag = avio_rb32(pb); + if (layout_tag == 0x10000) { //< kCAFChannelLayoutTag_UseChannelBitmap + codec->channel_layout = avio_rb32(pb); + avio_skip(pb, 4); + return; + } + while (caf_layout->channel_layout) { + if (layout_tag == caf_layout->layout_tag) { + codec->channel_layout = caf_layout->channel_layout; + break; + } + caf_layout++; + } + if (!codec->channel_layout) + av_log(s, AV_LOG_WARNING, "Unknown channel layout."); + avio_skip(pb, 8); +} + diff --git a/libavformat/caf.h b/libavformat/caf.h index 9c25f2c683..181cfaf92a 100644 --- a/libavformat/caf.h +++ b/libavformat/caf.h @@ -27,8 +27,11 @@ #ifndef AVFORMAT_CAF_H #define AVFORMAT_CAF_H +#include "avformat.h" #include "internal.h" extern const AVCodecTag ff_codec_caf_tags[]; +void ff_read_chan_chunk(AVFormatContext *s, int64_t size, AVCodecContext *codec); + #endif /* AVFORMAT_CAF_H */ diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 43d466f8c4..3cf4b6ca0c 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -257,6 +257,12 @@ static int read_header(AVFormatContext *s, read_info_chunk(s, size); break; + case MKBETAG('c','h','a','n'): + if (size < 12) + return AVERROR_INVALIDDATA; + ff_read_chan_chunk(s, size, st->codec); + break; + default: #define _(x) ((x) >= ' ' ? (x) : ' ') av_log(s, AV_LOG_WARNING, "skipping CAF chunk: %08X (%c%c%c%c), size %"PRId64"\n", From 8f2e438e52d4a6cd138968df18cd9e54d7f6394f Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 23 Apr 2011 10:31:03 +0200 Subject: [PATCH 123/172] Support channel layout when demuxing aif files. --- libavformat/Makefile | 2 +- libavformat/aiffdec.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 45871721b6..f83642f30c 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -23,7 +23,7 @@ OBJS-$(CONFIG_AC3_DEMUXER) += ac3dec.o rawdec.o OBJS-$(CONFIG_AC3_MUXER) += rawenc.o OBJS-$(CONFIG_ADTS_MUXER) += adtsenc.o OBJS-$(CONFIG_AEA_DEMUXER) += aea.o pcm.o -OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o riff.o pcm.o +OBJS-$(CONFIG_AIFF_DEMUXER) += aiffdec.o riff.o pcm.o caf.o OBJS-$(CONFIG_AIFF_MUXER) += aiffenc.o riff.o OBJS-$(CONFIG_AMR_DEMUXER) += amr.o OBJS-$(CONFIG_AMR_MUXER) += amr.o diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 25a93f5fb9..a3aecee0a8 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -23,6 +23,7 @@ #include "avformat.h" #include "pcm.h" #include "aiff.h" +#include "caf.h" #define AIFF 0 #define AIFF_C_VERSION1 0xA2805140 @@ -253,6 +254,11 @@ static int aiff_read_header(AVFormatContext *s, st->codec->extradata_size = size; avio_read(pb, st->codec->extradata, size); break; + case MKTAG('C','H','A','N'): + if (size < 12) + return AVERROR_INVALIDDATA; + ff_read_chan_chunk(s, size, st->codec); + break; default: /* Jump */ if (size & 1) /* Always even aligned */ size++; From ab1572609f58b718d77df0bd769ec2315ea6d09e Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 23 Apr 2011 10:41:44 +0200 Subject: [PATCH 124/172] 10l: Add misssing CR/LF. --- libavformat/caf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/caf.c b/libavformat/caf.c index d661406657..10daeda9fe 100644 --- a/libavformat/caf.c +++ b/libavformat/caf.c @@ -92,7 +92,7 @@ void ff_read_chan_chunk(AVFormatContext *s, int64_t size, AVCodecContext *codec) const CafChannelLayout *caf_layout = caf_channel_layout; if (size != 12) { // Channel descriptions not implemented - av_log_ask_for_sample(s, "Unimplemented channel layout."); + av_log_ask_for_sample(s, "Unimplemented channel layout.\n"); avio_skip(pb, size); return; } @@ -110,7 +110,7 @@ void ff_read_chan_chunk(AVFormatContext *s, int64_t size, AVCodecContext *codec) caf_layout++; } if (!codec->channel_layout) - av_log(s, AV_LOG_WARNING, "Unknown channel layout."); + av_log(s, AV_LOG_WARNING, "Unknown channel layout.\n"); avio_skip(pb, 8); } From 3d462373f8e8fa58b697a9b2d93a5edf70841937 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 23 Apr 2011 10:44:21 +0200 Subject: [PATCH 125/172] aac: add math.h needed for log2f() Signed-off-by: Michael Niedermayer --- libavcodec/aaccoder.c | 1 + libavcodec/aacsbr.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 60be5ef47d..9748fe1e1a 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -31,6 +31,7 @@ ***********************************/ #include +#include #include "avcodec.h" #include "put_bits.h" #include "aac.h" diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 117aa98875..6ac2cbc06a 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -35,6 +35,7 @@ #include #include +#include #define ENVELOPE_ADJUSTMENT_OFFSET 2 #define NOISE_FLOOR_OFFSET 6.0f From 230c1a90754860719b017a9ea4627dc81f67ff6e Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Wed, 5 Jan 2011 01:32:16 -0700 Subject: [PATCH 126/172] aacenc: Finish 3GPP psymodel analysis for non mid/side cases. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is still are still a few sections missing relating to TNS (not present) and mid/side (contains other bugs). Overall this improves quality, and vastly improves rate-control. Signed-off-by: Martin Storsjö --- libavcodec/aacenc.c | 4 +- libavcodec/aacpsy.c | 305 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 303 insertions(+), 6 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index d4b61126bd..4ec76d063a 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -606,8 +606,10 @@ static int aac_encode_frame(AVCodecContext *avctx, } frame_bits = put_bits_count(&s->pb); - if (frame_bits <= 6144 * avctx->channels - 3) + if (frame_bits <= 6144 * avctx->channels - 3) { + s->psy.bitres.bits = frame_bits / avctx->channels; break; + } s->lambda *= avctx->bit_rate * 1024.0f / avctx->sample_rate / frame_bits; diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 4250a5d763..98be176c0f 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -30,7 +30,6 @@ /*********************************** * TODOs: - * thresholds linearization after their modifications for attaining given bitrate * try other bitrate controlling mechanism (maybe use ratecontrol.c?) * control quality for quality-based output **********************************/ @@ -41,10 +40,51 @@ */ #define PSY_3GPP_THR_SPREAD_HI 1.5f // spreading factor for low-to-hi threshold spreading (15 dB/Bark) #define PSY_3GPP_THR_SPREAD_LOW 3.0f // spreading factor for hi-to-low threshold spreading (30 dB/Bark) +/* spreading factor for low-to-hi energy spreading, long block, > 22kbps/channel (20dB/Bark) */ +#define PSY_3GPP_EN_SPREAD_HI_L1 2.0f +/* spreading factor for low-to-hi energy spreading, long block, <= 22kbps/channel (15dB/Bark) */ +#define PSY_3GPP_EN_SPREAD_HI_L2 1.5f +/* spreading factor for low-to-hi energy spreading, short block (15 dB/Bark) */ +#define PSY_3GPP_EN_SPREAD_HI_S 1.5f +/* spreading factor for hi-to-low energy spreading, long block (30dB/Bark) */ +#define PSY_3GPP_EN_SPREAD_LOW_L 3.0f +/* spreading factor for hi-to-low energy spreading, short block (20dB/Bark) */ +#define PSY_3GPP_EN_SPREAD_LOW_S 2.0f #define PSY_3GPP_RPEMIN 0.01f #define PSY_3GPP_RPELEV 2.0f +#define PSY_3GPP_C1 3.0f /* log2(8) */ +#define PSY_3GPP_C2 1.3219281f /* log2(2.5) */ +#define PSY_3GPP_C3 0.55935729f /* 1 - C2 / C1 */ + +#define PSY_SNR_1DB 7.9432821e-1f /* -1dB */ +#define PSY_SNR_25DB 3.1622776e-3f /* -25dB */ + +#define PSY_3GPP_SAVE_SLOPE_L -0.46666667f +#define PSY_3GPP_SAVE_SLOPE_S -0.36363637f +#define PSY_3GPP_SAVE_ADD_L -0.84285712f +#define PSY_3GPP_SAVE_ADD_S -0.75f +#define PSY_3GPP_SPEND_SLOPE_L 0.66666669f +#define PSY_3GPP_SPEND_SLOPE_S 0.81818181f +#define PSY_3GPP_SPEND_ADD_L -0.35f +#define PSY_3GPP_SPEND_ADD_S -0.26111111f +#define PSY_3GPP_CLIP_LO_L 0.2f +#define PSY_3GPP_CLIP_LO_S 0.2f +#define PSY_3GPP_CLIP_HI_L 0.95f +#define PSY_3GPP_CLIP_HI_S 0.75f + +#define PSY_3GPP_AH_THR_LONG 0.5f +#define PSY_3GPP_AH_THR_SHORT 0.63f + +enum { + PSY_3GPP_AH_NONE, + PSY_3GPP_AH_INACTIVE, + PSY_3GPP_AH_ACTIVE +}; + +#define PSY_3GPP_BITS_TO_PE(bits) ((bits) * 1.18f) + /* LAME psy model constants */ #define PSY_LAME_FIR_LEN 21 ///< LAME psy model FIR order #define AAC_BLOCK_SIZE_LONG 1024 ///< long block size @@ -63,6 +103,12 @@ typedef struct AacPsyBand{ float energy; ///< band energy float thr; ///< energy threshold float thr_quiet; ///< threshold in quiet + float nz_lines; ///< number of non-zero spectral lines + float active_lines; ///< number of active spectral lines + float pe; ///< perceptual entropy + float pe_const; ///< constant part of the PE calculation + float norm_fac; ///< normalization factor for linearization + int avoid_holes; ///< hole avoidance flag }AacPsyBand; /** @@ -97,6 +143,15 @@ typedef struct AacPsyCoeffs{ * 3GPP TS26.403-inspired psychoacoustic model specific data */ typedef struct AacPsyContext{ + int chan_bitrate; ///< bitrate per channel + int frame_bits; ///< average bits per frame + int fill_level; ///< bit reservoir fill level + struct { + float min; ///< minimum allowed PE for bit factor calculation + float max; ///< maximum allowed PE for bit factor calculation + float previous; ///< allowed PE of the previous frame + float correction; ///< PE correction factor + } pe; AacPsyCoeffs psy_coef[2][64]; AacPsyChannel *ch; }AacPsyContext; @@ -235,16 +290,33 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { AacPsyContext *pctx; float bark; int i, j, g, start; - float prev, minscale, minath; + float prev, minscale, minath, minsnr, pe_min; + const int chan_bitrate = ctx->avctx->bit_rate / ctx->avctx->channels; + const int bandwidth = ctx->avctx->cutoff ? ctx->avctx->cutoff : ctx->avctx->sample_rate / 2; + const float num_bark = calc_bark((float)bandwidth); ctx->model_priv_data = av_mallocz(sizeof(AacPsyContext)); pctx = (AacPsyContext*) ctx->model_priv_data; + pctx->chan_bitrate = chan_bitrate; + pctx->frame_bits = chan_bitrate * AAC_BLOCK_SIZE_LONG / ctx->avctx->sample_rate; + pctx->pe.min = 8.0f * AAC_BLOCK_SIZE_LONG * bandwidth / (ctx->avctx->sample_rate * 2.0f); + pctx->pe.max = 12.0f * AAC_BLOCK_SIZE_LONG * bandwidth / (ctx->avctx->sample_rate * 2.0f); + ctx->bitres.size = 6144 - pctx->frame_bits; + ctx->bitres.size -= ctx->bitres.size % 8; + pctx->fill_level = ctx->bitres.size; minath = ath(3410, ATH_ADD); for (j = 0; j < 2; j++) { AacPsyCoeffs *coeffs = pctx->psy_coef[j]; const uint8_t *band_sizes = ctx->bands[j]; float line_to_frequency = ctx->avctx->sample_rate / (j ? 256.f : 2048.0f); + float avg_chan_bits = chan_bitrate / ctx->avctx->sample_rate * (j ? 128.0f : 1024.0f); + /* reference encoder uses 2.4% here instead of 60% like the spec says */ + float bark_pe = 0.024f * PSY_3GPP_BITS_TO_PE(avg_chan_bits) / num_bark; + float en_spread_low = j ? PSY_3GPP_EN_SPREAD_LOW_S : PSY_3GPP_EN_SPREAD_LOW_L; + /* High energy spreading for long blocks <= 22kbps/channel and short blocks are the same. */ + float en_spread_hi = (j || (chan_bitrate <= 22.0f)) ? PSY_3GPP_EN_SPREAD_HI_S : PSY_3GPP_EN_SPREAD_HI_L1; + i = 0; prev = 0.0; for (g = 0; g < ctx->num_bands[j]; g++) { @@ -258,6 +330,11 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { float bark_width = coeffs[g+1].barks - coeffs->barks; coeff->spread_low[0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_LOW); coeff->spread_hi [0] = pow(10.0, -bark_width * PSY_3GPP_THR_SPREAD_HI); + coeff->spread_low[1] = pow(10.0, -bark_width * en_spread_low); + coeff->spread_hi [1] = pow(10.0, -bark_width * en_spread_hi); + pe_min = bark_pe * bark_width; + minsnr = pow(2.0f, pe_min / band_sizes[g]) - 1.5f; + coeff->min_snr = av_clipf(1.0f / minsnr, PSY_SNR_25DB, PSY_SNR_1DB); } start = 0; for (g = 0; g < ctx->num_bands[j]; g++) { @@ -385,6 +462,97 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, return wi; } +/* 5.6.1.2 "Calculation of Bit Demand" */ +static int calc_bit_demand(AacPsyContext *ctx, float pe, int bits, int size, + int short_window) +{ + const float bitsave_slope = short_window ? PSY_3GPP_SAVE_SLOPE_S : PSY_3GPP_SAVE_SLOPE_L; + const float bitsave_add = short_window ? PSY_3GPP_SAVE_ADD_S : PSY_3GPP_SAVE_ADD_L; + const float bitspend_slope = short_window ? PSY_3GPP_SPEND_SLOPE_S : PSY_3GPP_SPEND_SLOPE_L; + const float bitspend_add = short_window ? PSY_3GPP_SPEND_ADD_S : PSY_3GPP_SPEND_ADD_L; + const float clip_low = short_window ? PSY_3GPP_CLIP_LO_S : PSY_3GPP_CLIP_LO_L; + const float clip_high = short_window ? PSY_3GPP_CLIP_HI_S : PSY_3GPP_CLIP_HI_L; + float clipped_pe, bit_save, bit_spend, bit_factor, fill_level; + + ctx->fill_level += ctx->frame_bits - bits; + ctx->fill_level = av_clip(ctx->fill_level, 0, size); + fill_level = av_clipf((float)ctx->fill_level / size, clip_low, clip_high); + clipped_pe = av_clipf(pe, ctx->pe.min, ctx->pe.max); + bit_save = (fill_level + bitsave_add) * bitsave_slope; + assert(bit_save <= 0.3f && bit_save >= -0.05000001f); + bit_spend = (fill_level + bitspend_add) * bitspend_slope; + assert(bit_spend <= 0.5f && bit_spend >= -0.1f); + /* The bit factor graph in the spec is obviously incorrect. + * bit_spend + ((bit_spend - bit_spend))... + * The reference encoder subtracts everything from 1, but also seems incorrect. + * 1 - bit_save + ((bit_spend + bit_save))... + * Hopefully below is correct. + */ + bit_factor = 1.0f - bit_save + ((bit_spend - bit_save) / (ctx->pe.max - ctx->pe.min)) * (clipped_pe - ctx->pe.min); + /* NOTE: The reference encoder attempts to center pe max/min around the current pe. */ + ctx->pe.max = FFMAX(pe, ctx->pe.max); + ctx->pe.min = FFMIN(pe, ctx->pe.min); + + return FFMIN(ctx->frame_bits * bit_factor, ctx->frame_bits + size - bits); +} + +static float calc_pe_3gpp(AacPsyBand *band) +{ + float pe, a; + + band->pe = 0.0f; + band->pe_const = 0.0f; + band->active_lines = 0.0f; + if (band->energy > band->thr) { + a = log2f(band->energy); + pe = a - log2f(band->thr); + band->active_lines = band->nz_lines; + if (pe < PSY_3GPP_C1) { + pe = pe * PSY_3GPP_C3 + PSY_3GPP_C2; + a = a * PSY_3GPP_C3 + PSY_3GPP_C2; + band->active_lines *= PSY_3GPP_C3; + } + band->pe = pe * band->nz_lines; + band->pe_const = a * band->nz_lines; + } + + return band->pe; +} + +static float calc_reduction_3gpp(float a, float desired_pe, float pe, + float active_lines) +{ + float thr_avg, reduction; + + thr_avg = powf(2.0f, (a - pe) / (4.0f * active_lines)); + reduction = powf(2.0f, (a - desired_pe) / (4.0f * active_lines)) - thr_avg; + + return FFMAX(reduction, 0.0f); +} + +static float calc_reduced_thr_3gpp(AacPsyBand *band, float min_snr, + float reduction) +{ + float thr = band->thr; + + if (band->energy > thr) { + thr = powf(thr, 0.25f) + reduction; + thr = powf(thr, 4.0f); + + /* This deviates from the 3GPP spec to match the reference encoder. + * It performs min(thr_reduced, max(thr, energy/min_snr)) only for bands + * that have hole avoidance on (active or inactive). It always reduces the + * threshold of bands with hole avoidance off. + */ + if (thr > band->energy * min_snr && band->avoid_holes != PSY_3GPP_AH_NONE) { + thr = FFMAX(band->thr, band->energy * min_snr); + band->avoid_holes = PSY_3GPP_AH_ACTIVE; + } + } + + return thr; +} + /** * Calculate band thresholds as suggested in 3GPP TS26.403 */ @@ -395,18 +563,27 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, AacPsyChannel *pch = &pctx->ch[channel]; int start = 0; int i, w, g; + float desired_bits, desired_pe, delta_pe, reduction, spread_en[128] = {0}; + float a = 0.0f, active_lines = 0.0f, norm_fac = 0.0f; + float pe = pctx->chan_bitrate > 32000 ? 0.0f : FFMAX(50.0f, 100.0f - pctx->chan_bitrate * 100.0f / 32000.0f); const int num_bands = ctx->num_bands[wi->num_windows == 8]; const uint8_t *band_sizes = ctx->bands[wi->num_windows == 8]; AacPsyCoeffs *coeffs = pctx->psy_coef[wi->num_windows == 8]; + const float avoid_hole_thr = wi->num_windows == 8 ? PSY_3GPP_AH_THR_SHORT : PSY_3GPP_AH_THR_LONG; //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation" for (w = 0; w < wi->num_windows*16; w += 16) { for (g = 0; g < num_bands; g++) { AacPsyBand *band = &pch->band[w+g]; + float form_factor = 0.0f; band->energy = 0.0f; - for (i = 0; i < band_sizes[g]; i++) + for (i = 0; i < band_sizes[g]; i++) { band->energy += coefs[start+i] * coefs[start+i]; + form_factor += sqrtf(fabs(coefs[start+i])); + } band->thr = band->energy * 0.001258925f; + band->nz_lines = form_factor / powf(band->energy / band_sizes[g], 0.25f); + start += band_sizes[g]; } } @@ -414,10 +591,15 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, for (w = 0; w < wi->num_windows*16; w += 16) { AacPsyBand *bands = &pch->band[w]; //5.4.2.3 "Spreading" & 5.4.3 "Spreaded Energy Calculation" - for (g = 1; g < num_bands; g++) + spread_en[0] = bands[0].energy; + for (g = 1; g < num_bands; g++) { bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]); - for (g = num_bands - 2; g >= 0; g--) + spread_en[w+g] = FFMAX(bands[g].energy, spread_en[w+g-1] * coeffs[g].spread_hi[1]); + } + for (g = num_bands - 2; g >= 0; g--) { bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]); + spread_en[w+g] = FFMAX(spread_en[w+g], spread_en[w+g+1] * coeffs[g].spread_low[1]); + } //5.4.2.4 "Threshold in quiet" for (g = 0; g < num_bands; g++) { AacPsyBand *band = &bands[g]; @@ -426,6 +608,119 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w))) band->thr = FFMAX(PSY_3GPP_RPEMIN*band->thr, FFMIN(band->thr, PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet)); + + /* 5.6.1.3.1 "Prepatory steps of the perceptual entropy calculation" */ + pe += calc_pe_3gpp(band); + a += band->pe_const; + active_lines += band->active_lines; + + /* 5.6.1.3.3 "Selection of the bands for avoidance of holes" */ + if (spread_en[w+g] * avoid_hole_thr > band->energy || coeffs[g].min_snr > 1.0f) + band->avoid_holes = PSY_3GPP_AH_NONE; + else + band->avoid_holes = PSY_3GPP_AH_INACTIVE; + } + } + + /* 5.6.1.3.2 "Calculation of the desired perceptual entropy" */ + ctx->pe[channel] = pe; + desired_bits = calc_bit_demand(pctx, pe, ctx->bitres.bits, ctx->bitres.size, wi->num_windows == 8); + desired_pe = PSY_3GPP_BITS_TO_PE(desired_bits); + /* NOTE: PE correction is kept simple. During initial testing it had very + * little effect on the final bitrate. Probably a good idea to come + * back and do more testing later. + */ + if (ctx->bitres.bits > 0) + desired_pe *= av_clipf(pctx->pe.previous / PSY_3GPP_BITS_TO_PE(ctx->bitres.bits), + 0.85f, 1.15f); + pctx->pe.previous = PSY_3GPP_BITS_TO_PE(desired_bits); + + if (desired_pe < pe) { + /* 5.6.1.3.4 "First Estimation of the reduction value" */ + for (w = 0; w < wi->num_windows*16; w += 16) { + reduction = calc_reduction_3gpp(a, desired_pe, pe, active_lines); + pe = 0.0f; + a = 0.0f; + active_lines = 0.0f; + for (g = 0; g < num_bands; g++) { + AacPsyBand *band = &pch->band[w+g]; + + band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction); + /* recalculate PE */ + pe += calc_pe_3gpp(band); + a += band->pe_const; + active_lines += band->active_lines; + } + } + + /* 5.6.1.3.5 "Second Estimation of the reduction value" */ + for (i = 0; i < 2; i++) { + float pe_no_ah = 0.0f, desired_pe_no_ah; + active_lines = a = 0.0f; + for (w = 0; w < wi->num_windows*16; w += 16) { + for (g = 0; g < num_bands; g++) { + AacPsyBand *band = &pch->band[w+g]; + + if (band->avoid_holes != PSY_3GPP_AH_ACTIVE) { + pe_no_ah += band->pe; + a += band->pe_const; + active_lines += band->active_lines; + } + } + } + desired_pe_no_ah = FFMAX(desired_pe - (pe - pe_no_ah), 0.0f); + if (active_lines > 0.0f) + reduction += calc_reduction_3gpp(a, desired_pe_no_ah, pe_no_ah, active_lines); + + pe = 0.0f; + for (w = 0; w < wi->num_windows*16; w += 16) { + for (g = 0; g < num_bands; g++) { + AacPsyBand *band = &pch->band[w+g]; + + if (active_lines > 0.0f) + band->thr = calc_reduced_thr_3gpp(band, coeffs[g].min_snr, reduction); + pe += calc_pe_3gpp(band); + band->norm_fac = band->active_lines / band->thr; + norm_fac += band->norm_fac; + } + } + delta_pe = desired_pe - pe; + if (fabs(delta_pe) > 0.05f * desired_pe) + break; + } + + if (pe < 1.15f * desired_pe) { + /* 6.6.1.3.6 "Final threshold modification by linearization" */ + norm_fac = 1.0f / norm_fac; + for (w = 0; w < wi->num_windows*16; w += 16) { + for (g = 0; g < num_bands; g++) { + AacPsyBand *band = &pch->band[w+g]; + + if (band->active_lines > 0.5f) { + float delta_sfb_pe = band->norm_fac * norm_fac * delta_pe; + float thr = band->thr; + + thr *= powf(2.0f, delta_sfb_pe / band->active_lines); + if (thr > coeffs[g].min_snr * band->energy && band->avoid_holes == PSY_3GPP_AH_INACTIVE) + thr = FFMAX(band->thr, coeffs[g].min_snr * band->energy); + band->thr = thr; + } + } + } + } else { + /* 5.6.1.3.7 "Further perceptual entropy reduction" */ + g = num_bands; + while (pe > desired_pe && g--) { + for (w = 0; w < wi->num_windows*16; w+= 16) { + AacPsyBand *band = &pch->band[w+g]; + if (band->avoid_holes != PSY_3GPP_AH_NONE && coeffs[g].min_snr < PSY_SNR_1DB) { + coeffs[g].min_snr = PSY_SNR_1DB; + band->thr = band->energy * PSY_SNR_1DB; + pe += band->active_lines * 1.5f - band->pe; + } + } + } + /* TODO: allow more holes (unused without mid/side) */ } } From 62582a696b4dbe3d644ea19aa6739bbe592482da Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 23 Apr 2011 02:02:42 +0200 Subject: [PATCH 127/172] cook: Fix small typo in av_log_ask_for_sample message. --- libavcodec/cook.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 282ca1029d..f1df2405f6 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1136,7 +1136,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) switch (q->subpacket[s].cookversion) { case MONO: if (q->nb_channels != 1) { - av_log_ask_for_sample(avctx, "Container channels != 1.!\n"); + av_log_ask_for_sample(avctx, "Container channels != 1.\n"); return -1; } av_log(avctx,AV_LOG_DEBUG,"MONO\n"); From cd1872799d89a87b1d06132118836c82cda2a44f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 23 Apr 2011 00:07:15 +0200 Subject: [PATCH 128/172] flicvideo: increase error level and fix error message in CHECK_PIXEL_PTR() Also return AVERROR_INVALIDDATA rather than -1. Signed-off-by: Stefano Sabatini --- libavcodec/flicvideo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index 913617d120..126c4e1a04 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -61,9 +61,9 @@ #define CHECK_PIXEL_PTR(n) \ if (pixel_ptr + n > pixel_limit) { \ - av_log (s->avctx, AV_LOG_INFO, "Problem: pixel_ptr >= pixel_limit (%d >= %d)\n", \ + av_log (s->avctx, AV_LOG_ERROR, "Invalid pixel_ptr = %d > pixel_limit = %d\n", \ pixel_ptr + n, pixel_limit); \ - return -1; \ + return AVERROR_INVALIDDATA; \ } \ typedef struct FlicDecodeContext { From efd6cbc5ddac2d4df7008733bfef1d6d6809cc3c Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 23 Apr 2011 00:08:28 +0200 Subject: [PATCH 129/172] flicvideo: fix crash on flic files with invalid frame size Add a check in flic_decode_frame_8BPP(), in case chunk_size is > frame_size issue a warning and resize chunk_size to frame_size, in order to avoid out-of-buffer reads. Fix roundup issue #2520, trac issue #69. Signed-off-by: Stefano Sabatini --- libavcodec/flicvideo.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index 126c4e1a04..7d2fd87647 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -181,6 +181,11 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, /* iterate through the chunks */ while ((frame_size > 0) && (num_chunks > 0)) { chunk_size = AV_RL32(&buf[stream_ptr]); + if (chunk_size > frame_size) { + av_log(avctx, AV_LOG_WARNING, + "Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size); + chunk_size = frame_size; + } stream_ptr += 4; chunk_type = AV_RL16(&buf[stream_ptr]); stream_ptr += 2; From ab7fdbab00872f6435cd1b6b5f1304e2d03d86eb Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 22 Apr 2011 02:19:48 +0200 Subject: [PATCH 130/172] ffplay: rename stream_pause() to stream_toggle_pause() The new name is less misleading, since the function will resume the stream if it is currently paused. Signed-off-by: Stefano Sabatini --- ffplay.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ffplay.c b/ffplay.c index eb5b278966..28ec615b3e 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1064,7 +1064,7 @@ static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_by } /* pause or resume the video */ -static void stream_pause(VideoState *is) +static void stream_toggle_pause(VideoState *is) { if (is->paused) { is->frame_timer += av_gettime() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts; @@ -1865,7 +1865,7 @@ static int video_thread(void *arg) if (step) if (cur_stream) - stream_pause(cur_stream); + stream_toggle_pause(cur_stream); } the_end: #if CONFIG_AVFILTER @@ -1944,7 +1944,7 @@ static int subtitle_thread(void *arg) av_free_packet(pkt); // if (step) // if (cur_stream) -// stream_pause(cur_stream); +// stream_toggle_pause(cur_stream); } the_end: return 0; @@ -2713,7 +2713,7 @@ static void toggle_full_screen(void) static void toggle_pause(void) { if (cur_stream) - stream_pause(cur_stream); + stream_toggle_pause(cur_stream); step = 0; } @@ -2722,7 +2722,7 @@ static void step_to_next_frame(void) if (cur_stream) { /* if the stream is paused unpause it, then step */ if (cur_stream->paused) - stream_pause(cur_stream); + stream_toggle_pause(cur_stream); } step = 1; } From c632a1c205c59a7d716cae2d540c7b693e9a827e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 22 Apr 2011 11:26:44 +0200 Subject: [PATCH 131/172] ffplay: remove reference to unused QETimer symbol Signed-off-by: Stefano Sabatini --- ffplay.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 28ec615b3e..f97d97ff9b 100644 --- a/ffplay.c +++ b/ffplay.c @@ -206,7 +206,6 @@ typedef struct VideoState { struct SwsContext *img_convert_ctx; #endif - // QETimer *video_timer; char filename[1024]; int width, height, xleft, ytop; From 539647c6ffa9c39f60cee41e1eb79e491bc4f4c5 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 22 Apr 2011 11:09:48 +0200 Subject: [PATCH 132/172] ffplay: factorize code calling output_packet() in video_thread() Slightly simplify. Signed-off-by: Stefano Sabatini --- ffplay.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ffplay.c b/ffplay.c index f97d97ff9b..eb08f36a6a 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1803,14 +1803,13 @@ static int video_thread(void *arg) { VideoState *is = arg; AVFrame *frame= avcodec_alloc_frame(); - int64_t pts_int; + int64_t pts_int, pos; double pts; int ret; #if CONFIG_AVFILTER AVFilterGraph *graph = avfilter_graph_alloc(); AVFilterContext *filt_out = NULL; - int64_t pos; if ((ret = configure_video_filters(graph, is, vfilters)) < 0) goto the_end; @@ -1844,6 +1843,7 @@ static int video_thread(void *arg) } #else ret = get_video_frame(is, frame, &pts_int, &pkt); + pos = pkt.pos; #endif if (ret < 0) goto the_end; @@ -1853,10 +1853,8 @@ static int video_thread(void *arg) pts = pts_int*av_q2d(is->video_st->time_base); -#if CONFIG_AVFILTER ret = output_picture(is, frame, pts, pos); -#else - ret = output_picture(is, frame, pts, pkt.pos); +#if !CONFIG_AVFILTER av_free_packet(&pkt); #endif if (ret < 0) From 2ef2496cd19eb833f4ad22a5051c11be80d09598 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 23 Apr 2011 13:37:28 +0200 Subject: [PATCH 133/172] Set channel layout in flac decoder. --- libavcodec/Makefile | 2 +- libavcodec/flac.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 62ac8999a8..1561954a97 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -140,7 +140,7 @@ OBJS-$(CONFIG_FFV1_DECODER) += ffv1.o rangecoder.o OBJS-$(CONFIG_FFV1_ENCODER) += ffv1.o rangecoder.o OBJS-$(CONFIG_FFVHUFF_DECODER) += huffyuv.o OBJS-$(CONFIG_FFVHUFF_ENCODER) += huffyuv.o -OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o +OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o vorbis_data.o OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o diff --git a/libavcodec/flac.c b/libavcodec/flac.c index 484a44efb3..6e94c2c5ff 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -22,6 +22,7 @@ #include "libavutil/crc.h" #include "flac.h" #include "flacdata.h" +#include "vorbis.h" static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; @@ -54,6 +55,8 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, fi->ch_mode = get_bits(gb, 4); if (fi->ch_mode < FLAC_MAX_CHANNELS) { fi->channels = fi->ch_mode + 1; + if (fi->ch_mode <= 5) + avctx->channel_layout = ff_vorbis_channel_layouts[fi->ch_mode]; fi->ch_mode = FLAC_CHMODE_INDEPENDENT; } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) { fi->channels = 2; From f50d9377252431114e89514cf528825936efcbd9 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Tue, 5 Apr 2011 01:05:24 -0600 Subject: [PATCH 134/172] aacenc: Fix whitespace after last commit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/aacpsy.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c index 98be176c0f..5aea1faa40 100644 --- a/libavcodec/aacpsy.c +++ b/libavcodec/aacpsy.c @@ -100,9 +100,9 @@ enum { * information for single band used by 3GPP TS26.403-inspired psychoacoustic model */ typedef struct AacPsyBand{ - float energy; ///< band energy - float thr; ///< energy threshold - float thr_quiet; ///< threshold in quiet + float energy; ///< band energy + float thr; ///< energy threshold + float thr_quiet; ///< threshold in quiet float nz_lines; ///< number of non-zero spectral lines float active_lines; ///< number of active spectral lines float pe; ///< perceptual entropy @@ -566,43 +566,46 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, float desired_bits, desired_pe, delta_pe, reduction, spread_en[128] = {0}; float a = 0.0f, active_lines = 0.0f, norm_fac = 0.0f; float pe = pctx->chan_bitrate > 32000 ? 0.0f : FFMAX(50.0f, 100.0f - pctx->chan_bitrate * 100.0f / 32000.0f); - const int num_bands = ctx->num_bands[wi->num_windows == 8]; - const uint8_t *band_sizes = ctx->bands[wi->num_windows == 8]; - AacPsyCoeffs *coeffs = pctx->psy_coef[wi->num_windows == 8]; + const int num_bands = ctx->num_bands[wi->num_windows == 8]; + const uint8_t *band_sizes = ctx->bands[wi->num_windows == 8]; + AacPsyCoeffs *coeffs = pctx->psy_coef[wi->num_windows == 8]; const float avoid_hole_thr = wi->num_windows == 8 ? PSY_3GPP_AH_THR_SHORT : PSY_3GPP_AH_THR_LONG; //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation" for (w = 0; w < wi->num_windows*16; w += 16) { for (g = 0; g < num_bands; g++) { AacPsyBand *band = &pch->band[w+g]; + float form_factor = 0.0f; band->energy = 0.0f; for (i = 0; i < band_sizes[g]; i++) { band->energy += coefs[start+i] * coefs[start+i]; form_factor += sqrtf(fabs(coefs[start+i])); } - band->thr = band->energy * 0.001258925f; + band->thr = band->energy * 0.001258925f; band->nz_lines = form_factor / powf(band->energy / band_sizes[g], 0.25f); - start += band_sizes[g]; + start += band_sizes[g]; } } //modify thresholds and energies - spread, threshold in quiet, pre-echo control for (w = 0; w < wi->num_windows*16; w += 16) { AacPsyBand *bands = &pch->band[w]; + //5.4.2.3 "Spreading" & 5.4.3 "Spreaded Energy Calculation" spread_en[0] = bands[0].energy; for (g = 1; g < num_bands; g++) { - bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]); + bands[g].thr = FFMAX(bands[g].thr, bands[g-1].thr * coeffs[g].spread_hi[0]); spread_en[w+g] = FFMAX(bands[g].energy, spread_en[w+g-1] * coeffs[g].spread_hi[1]); } for (g = num_bands - 2; g >= 0; g--) { - bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]); + bands[g].thr = FFMAX(bands[g].thr, bands[g+1].thr * coeffs[g].spread_low[0]); spread_en[w+g] = FFMAX(spread_en[w+g], spread_en[w+g+1] * coeffs[g].spread_low[1]); } //5.4.2.4 "Threshold in quiet" for (g = 0; g < num_bands; g++) { AacPsyBand *band = &bands[g]; + band->thr_quiet = band->thr = FFMAX(band->thr, coeffs[g].ath); //5.4.2.5 "Pre-echo control" if (!(wi->window_type[0] == LONG_STOP_SEQUENCE || (wi->window_type[1] == LONG_START_SEQUENCE && !w))) From 046f3cb78903cd04846c49345b473244f095f1a5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 17 Apr 2011 19:44:33 +0200 Subject: [PATCH 135/172] vorbis: Rename decoder/encoder files to follow general file naming scheme. --- libavcodec/Makefile | 4 ++-- libavcodec/twinvq.c | 2 +- libavcodec/{vorbis_dec.c => vorbisdec.c} | 0 libavcodec/{vorbis_enc.c => vorbisenc.c} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename libavcodec/{vorbis_dec.c => vorbisdec.c} (100%) rename libavcodec/{vorbis_enc.c => vorbisenc.c} (100%) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 784226f7af..fad435dee3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -386,9 +386,9 @@ OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdav.o OBJS-$(CONFIG_VMNC_DECODER) += vmnc.o -OBJS-$(CONFIG_VORBIS_DECODER) += vorbis_dec.o vorbis.o \ +OBJS-$(CONFIG_VORBIS_DECODER) += vorbisdec.o vorbis.o \ vorbis_data.o xiph.o -OBJS-$(CONFIG_VORBIS_ENCODER) += vorbis_enc.o vorbis.o \ +OBJS-$(CONFIG_VORBIS_ENCODER) += vorbisenc.o vorbis.o \ vorbis_data.o OBJS-$(CONFIG_VP3_DECODER) += vp3.o vp3dsp.o OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56dsp.o \ diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index e1a8dc455b..985f71c8ca 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -234,7 +234,7 @@ static void memset_float(float *buf, float val, int size) * be a multiple of four. * @return the LPC value * - * @todo reuse code from vorbis_dec.c: vorbis_floor0_decode + * @todo reuse code from Vorbis decoder: vorbis_floor0_decode */ static float eval_lpc_spectrum(const float *lsp, float cos_val, int order) { diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbisdec.c similarity index 100% rename from libavcodec/vorbis_dec.c rename to libavcodec/vorbisdec.c diff --git a/libavcodec/vorbis_enc.c b/libavcodec/vorbisenc.c similarity index 100% rename from libavcodec/vorbis_enc.c rename to libavcodec/vorbisenc.c From 75e8fba8232108c075a8b24bd7f17b7c5869c7bc Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 23 Apr 2011 14:14:22 +0200 Subject: [PATCH 136/172] Remove stray libavcore and _g binary references. --- .gitignore | 2 -- Changelog | 1 - 2 files changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index eac1758ed9..3d5e38b6bd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ *.ho *-example *-test -*_g config.* doc/*.1 doc/*.html @@ -17,7 +16,6 @@ ffplay ffprobe ffserver libavcodec/libavcodec* -libavcore/libavcore* libavdevice/libavdevice* libavfilter/libavfilter* libavformat/libavformat* diff --git a/Changelog b/Changelog index f38ef9eec5..00777e4e6a 100644 --- a/Changelog +++ b/Changelog @@ -27,7 +27,6 @@ version 0.7_beta1: - RTP depacketization of QDM2 - ANSI/ASCII art playback system - Lego Mindstorms RSO de/muxer -- libavcore added - SubRip subtitle file muxer and demuxer - Chinese AVS encoding via libxavs - ffprobe -show_packets option added From ff3be572efde575c2b5ee621a84920ac9a5b9b8f Mon Sep 17 00:00:00 2001 From: Brad Date: Sun, 27 Mar 2011 21:05:22 -0400 Subject: [PATCH 137/172] patcheck: Allow overiding grep program(s) through environment variables. patcheck hardcodes the binary names for grep/egrep. This makes overriding the binary names a pain, e.g. when calling a GNU version of grep on BSD systems. Signed-off-by: Diego Biurrun --- tools/patcheck | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/tools/patcheck b/tools/patcheck index e21a9f681d..d81a48937f 100755 --- a/tools/patcheck +++ b/tools/patcheck @@ -8,9 +8,11 @@ if [ $# = 0 ]; then exit fi +GREP=grep +EGREP=egrep TMP=patcheck.tmp OPT="-nH" -#FILES=`grep '^+++' $* | sed 's/+++ //g'` +#FILES=`$GREP '^+++' $* | sed 's/+++ //g'` echo patCHeck 1e10.0 echo This tool is intended to help a human check/review patches it is very far from @@ -27,7 +29,7 @@ hiegrep(){ arg="$1" msg="$2" shift 2 - grep $OPT '^+' $* | grep -v ':+++'| egrep --color=always -- "$arg"> $TMP && printf "\n$msg\n" + $GREP $OPT '^+' $* | $GREP -v ':+++'| $EGREP --color=always -- "$arg"> $TMP && printf "\n$msg\n" cat $TMP } @@ -36,7 +38,7 @@ hiegrep2(){ varg="$2" msg="$3" shift 3 - grep $OPT '^+' $* | grep -v ':+++' | egrep -v -- "$varg" | egrep --color=always -- "$arg" > $TMP && printf "\n$msg\n" + $GREP $OPT '^+' $* | $GREP -v ':+++' | $EGREP -v -- "$varg" | $EGREP --color=always -- "$arg" > $TMP && printf "\n$msg\n" cat $TMP } @@ -60,7 +62,7 @@ hiegrep '\+= *1 *;' 'can be simplified to ++' $* hiegrep '-= *1 *;' 'can be simplified to --' $* hiegrep '((!|=)= *(0|NULL)[^0-9a-z]|[^0-9a-z](0|NULL) *(!|=)=)' 'x==0 / x!=0 can be simplified to !x / x' $* -egrep $OPT '^\+ *(const *|)static' $*| egrep --color=always '[^=]= *(0|NULL)[^0-9a-zA-Z]'> $TMP && printf '\nuseless 0 init\n' +$EGREP $OPT '^\+ *(const *|)static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^0-9a-zA-Z]'> $TMP && printf '\nuseless 0 init\n' cat $TMP hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $* @@ -89,7 +91,7 @@ hiegrep2 '\.sample_fmts *= *\(' 'const' 'missing const for sample_fmts array' $* hiegrep2 '\.supported_framerates *= *\(' 'const' 'missing const for supported_framerates array' $* hiegrep2 '\.channel_layouts *= *\(' 'const' 'missing const for channel_layouts array' $* -#egrep $OPT '^\+.*const ' $*| grep -v 'static'> $TMP && printf '\nnon static const\n' +#$EGREP $OPT '^\+.*const ' $*| $GREP -v 'static'> $TMP && printf '\nnon static const\n' #cat $TMP hiegrep2 "$ERE_TYPES" '(static|av_|ff_|typedef|:\+[^a-zA-Z_])' 'Non static with no ff_/av_ prefix' $* @@ -104,58 +106,58 @@ hiegrep ':\+ *{ *$' '{ should be on the same line as the related previous state rm $TMP -for i in `grep -H '^+.*@param' $*| sed 's/^\([^:]*\):.*@param\(\[.*\]\|\) *\([a-zA-Z0-9_]*\) .*$/\1:\3/'` ; do +for i in `$GREP -H '^+.*@param' $*| sed 's/^\([^:]*\):.*@param\(\[.*\]\|\) *\([a-zA-Z0-9_]*\) .*$/\1:\3/'` ; do doxpar=`echo $i | sed 's/^.*:\(.*\)$/\1/'` file=`echo $i | sed 's/^\([^:]*\):.*$/\1/'` - grep " *$doxpar *[),]" $file | grep -v '@param' >/dev/null || grep --color=always "@param *$doxpar" $file >>$TMP + $GREP " *$doxpar *[),]" $file | $GREP -v '@param' >/dev/null || $GREP --color=always "@param *$doxpar" $file >>$TMP done if test -e $TMP ; then printf '\nmismatching doxy params\n' cat $TMP fi -egrep -B2 $OPT '^(\+|) *('"$ERE_TYPES"'|# *define)' $* | egrep -A2 --color=always '(:|-)\+[^/]*/(\*([^*]|$)|/([^/]|$))' > $TMP && printf "\n Non doxy comments\n" +$EGREP -B2 $OPT '^(\+|) *('"$ERE_TYPES"'|# *define)' $* | $EGREP -A2 --color=always '(:|-)\+[^/]*/(\*([^*]|$)|/([^/]|$))' > $TMP && printf "\n Non doxy comments\n" cat $TMP rm $TMP for i in \ - `egrep -H '^\+ *'"$ERE_TYPES" $* |\ - grep -v '(' | egrep -v '\Wgoto\W' |\ + `$EGREP -H '^\+ *'"$ERE_TYPES" $* |\ + $GREP -v '(' | $EGREP -v '\Wgoto\W' |\ xargs -d '\n' -n 1 |\ - grep -o '[* ][* ]*[a-zA-Z][0-9a-zA-Z_]* *[,;=]' |\ + $GREP -o '[* ][* ]*[a-zA-Z][0-9a-zA-Z_]* *[,;=]' |\ sed 's/.[* ]*\([a-zA-Z][0-9a-zA-Z_]*\) *[,;=]/\1/'` \ ; do - echo $i | grep '^NULL$' && continue - egrep $i' *(\+|-|\*|/|\||&|%|)=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP - egrep '(=|\(|return).*'$i'(==|[^=])*$' $* >/dev/null || echo "possibly never read :"$i >> $TMP - egrep -o $i' *((\+|-|\*|/|\||&|%|)=[^=]|\+\+|--) *(0x|)[0-9]*(;|)' $* |\ - egrep -v $i' *= *(0x|)[0-9]{1,};'>/dev/null || echo "possibly constant :"$i >> $TMP + echo $i | $GREP '^NULL$' && continue + $EGREP $i' *(\+|-|\*|/|\||&|%|)=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP + $EGREP '(=|\(|return).*'$i'(==|[^=])*$' $* >/dev/null || echo "possibly never read :"$i >> $TMP + $EGREP -o $i' *((\+|-|\*|/|\||&|%|)=[^=]|\+\+|--) *(0x|)[0-9]*(;|)' $* |\ + $EGREP -v $i' *= *(0x|)[0-9]{1,};'>/dev/null || echo "possibly constant :"$i >> $TMP done if test -e $TMP ; then printf '\npossibly unused variables\n' cat $TMP fi -grep '^+++ .*Changelog' $* >/dev/null || printf "\nMissing changelog entry (ignore if minor change)\n" +$GREP '^+++ .*Changelog' $* >/dev/null || printf "\nMissing changelog entry (ignore if minor change)\n" -cat $* | tr '\n' '@' | egrep --color=always -o '(fprintf|av_log|printf)\([^)]*\)[+ ;@]*\1' >$TMP && printf "\nMergeable calls\n" +cat $* | tr '\n' '@' | $EGREP --color=always -o '(fprintf|av_log|printf)\([^)]*\)[+ ;@]*\1' >$TMP && printf "\nMergeable calls\n" cat $TMP | tr '@' '\n' -cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *[0-9]* *\) * \1 *= *[0-9]* *;[ @\\+]*else *if *\( *\1 *[<>]=? *[0-9]* *\) *\1 *= *[0-9]* *;' >$TMP && printf "\nav_clip / av_clip_uint8 / av_clip_int16 / ...\n" +cat $* | tr '\n' '@' | $EGREP --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *[0-9]* *\) * \1 *= *[0-9]* *;[ @\\+]*else *if *\( *\1 *[<>]=? *[0-9]* *\) *\1 *= *[0-9]* *;' >$TMP && printf "\nav_clip / av_clip_uint8 / av_clip_int16 / ...\n" cat $TMP | tr '@' '\n' -cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *([A-Za-z0-9_]*) *\)[ @\\+]*(\1|\2) *= *(\1|\2) *;' >$TMP && printf "\nFFMIN/FFMAX\n" +cat $* | tr '\n' '@' | $EGREP --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *([A-Za-z0-9_]*) *\)[ @\\+]*(\1|\2) *= *(\1|\2) *;' >$TMP && printf "\nFFMIN/FFMAX\n" cat $TMP | tr '@' '\n' -cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *\)[ @\\+]*av_free(p|) *\( *(&|) *\1[^-.]' >$TMP && printf "\nav_free(NULL) is safe\n" +cat $* | tr '\n' '@' | $EGREP --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *\)[ @\\+]*av_free(p|) *\( *(&|) *\1[^-.]' >$TMP && printf "\nav_free(NULL) is safe\n" cat $TMP | tr '@' '\n' -cat $* | tr '\n' '@' | egrep --color=always -o '[^a-zA-Z0-9_]([a-zA-Z0-9_]*) *= *av_malloc *\([^)]*\)[ @;\\+]*memset *\( *\1' >$TMP && printf "\nav_mallocz()\n" +cat $* | tr '\n' '@' | $EGREP --color=always -o '[^a-zA-Z0-9_]([a-zA-Z0-9_]*) *= *av_malloc *\([^)]*\)[ @;\\+]*memset *\( *\1' >$TMP && printf "\nav_mallocz()\n" cat $TMP | tr '@' '\n' # doesnt work -#cat $* | tr '\n' '@' | egrep -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1' | egrep -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1 *=[^=]' >$TMP && printf "\nPossibly written 2x before read\n" +#cat $* | tr '\n' '@' | $EGREP -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1' | $EGREP -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1 *=[^=]' >$TMP && printf "\nPossibly written 2x before read\n" #cat $TMP | tr '@' '\n' exit @@ -163,7 +165,7 @@ exit TODO/idea list: for all demuxers & muxers - grep for "avctx->priv_data" + $EGREP for "avctx->priv_data" vertical align = /* and * align From 6252040e773c30efa21c743124d5e813320a0ec2 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 19 Apr 2011 00:16:24 +0200 Subject: [PATCH 138/172] Replace `` by $() syntax in shell scripts. $() is easier to nest and POSIX, which we require in other places. --- tools/clean-diff | 2 +- tools/patcheck | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/clean-diff b/tools/clean-diff index 98e26a79f9..4600702b10 100755 --- a/tools/clean-diff +++ b/tools/clean-diff @@ -1,6 +1,6 @@ #!/bin/sh sed '/^+[^+]/!s/ /TaBBaT/g' |\ - expand -t `seq -s , 9 8 200` |\ + expand -t $(seq -s , 9 8 200) |\ sed 's/TaBBaT/ /g' |\ sed '/^+[^+]/s/ * $//' |\ tr -d '\015' |\ diff --git a/tools/patcheck b/tools/patcheck index d81a48937f..a8c0cc8cf7 100755 --- a/tools/patcheck +++ b/tools/patcheck @@ -12,7 +12,7 @@ GREP=grep EGREP=egrep TMP=patcheck.tmp OPT="-nH" -#FILES=`$GREP '^+++' $* | sed 's/+++ //g'` +#FILES=$($GREP '^+++' $* | sed 's/+++ //g') echo patCHeck 1e10.0 echo This tool is intended to help a human check/review patches it is very far from @@ -43,7 +43,7 @@ hiegrep2(){ } hiegrep '[[:space:]]$' 'trailing whitespace' $* -hiegrep "`echo x | tr 'x' '\t'`" 'tabs' $* +hiegrep "$(echo x | tr 'x' '\t')" 'tabs' $* #hiegrep ':\+$' 'Empty lines' $* hiegrep ';;' 'double ;' $* hiegrep2 '\b_[a-zA-Z0-9_]{1,}' '__(asm|attribute)([^a-zA-Z0-9]|$)' 'reserved identifer' $* @@ -106,9 +106,9 @@ hiegrep ':\+ *{ *$' '{ should be on the same line as the related previous state rm $TMP -for i in `$GREP -H '^+.*@param' $*| sed 's/^\([^:]*\):.*@param\(\[.*\]\|\) *\([a-zA-Z0-9_]*\) .*$/\1:\3/'` ; do - doxpar=`echo $i | sed 's/^.*:\(.*\)$/\1/'` - file=`echo $i | sed 's/^\([^:]*\):.*$/\1/'` +for i in $($GREP -H '^+.*@param' $*| sed 's/^\([^:]*\):.*@param\(\[.*\]\|\) *\([a-zA-Z0-9_]*\) .*$/\1:\3/') ; do + doxpar=$(echo $i | sed 's/^.*:\(.*\)$/\1/') + file=$(echo $i | sed 's/^\([^:]*\):.*$/\1/') $GREP " *$doxpar *[),]" $file | $GREP -v '@param' >/dev/null || $GREP --color=always "@param *$doxpar" $file >>$TMP done if test -e $TMP ; then @@ -121,11 +121,11 @@ cat $TMP rm $TMP for i in \ - `$EGREP -H '^\+ *'"$ERE_TYPES" $* |\ + $($EGREP -H '^\+ *'"$ERE_TYPES" $* |\ $GREP -v '(' | $EGREP -v '\Wgoto\W' |\ xargs -d '\n' -n 1 |\ $GREP -o '[* ][* ]*[a-zA-Z][0-9a-zA-Z_]* *[,;=]' |\ - sed 's/.[* ]*\([a-zA-Z][0-9a-zA-Z_]*\) *[,;=]/\1/'` \ + sed 's/.[* ]*\([a-zA-Z][0-9a-zA-Z_]*\) *[,;=]/\1/') \ ; do echo $i | $GREP '^NULL$' && continue $EGREP $i' *(\+|-|\*|/|\||&|%|)=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP From 43fb279f5643225799841f512d2dad4690186165 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 23 Apr 2011 16:39:03 +0200 Subject: [PATCH 139/172] Replace more FFmpeg instances by Libav or ffmpeg. --- doc/general.texi | 2 +- doc/issue_tracker.txt | 2 +- ffserver.c | 2 +- libavcodec/avcodec.h | 6 +++--- libavcodec/dca.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index 303159eba7..e68e83e5f2 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -268,7 +268,7 @@ library: @section Image Formats -FFmpeg can read and write images for each frame of a video sequence. The +Libav can read and write images for each frame of a video sequence. The following image formats are supported: @multitable @columnfractions .4 .1 .1 .4 diff --git a/doc/issue_tracker.txt b/doc/issue_tracker.txt index 5a15a9b665..e5733ec9d5 100644 --- a/doc/issue_tracker.txt +++ b/doc/issue_tracker.txt @@ -39,7 +39,7 @@ NOTE: issue = (bug report || patch || feature request) Type: ----- bug - An error, flaw, mistake, failure, or fault in FFmpeg or libav* that + An error, flaw, mistake, failure, or fault in ffmpeg or libav* that prevents it from behaving as intended. feature request diff --git a/ffserver.c b/ffserver.c index d341182a4f..9cb65da017 100644 --- a/ffserver.c +++ b/ffserver.c @@ -2265,7 +2265,7 @@ static int http_prepare_data(HTTPContext *c) /* * HACK to avoid mpeg ps muxer to spit many underflow errors - * Default value from FFmpeg + * Default value from Libav * Try to set it use configuration option */ c->fmt_ctx.preload = (int)(0.5*AV_TIME_BASE); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 14f00bb5d0..ec31f666d1 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -960,7 +960,7 @@ typedef struct AVPanScan{ int64_t reordered_opaque;\ \ /**\ - * hardware accelerator private data (FFmpeg allocated)\ + * hardware accelerator private data (Libav-allocated)\ * - encoding: unused\ * - decoding: Set by libavcodec\ */\ @@ -2633,8 +2633,8 @@ typedef struct AVCodecContext { * Hardware accelerator context. * For some hardware accelerators, a global context needs to be * provided by the user. In that case, this holds display-dependent - * data FFmpeg cannot instantiate itself. Please refer to the - * FFmpeg HW accelerator documentation to know how to fill this + * data Libav cannot instantiate itself. Please refer to the + * Libav HW accelerator documentation to know how to fill this * is. e.g. for VA API, this is a struct vaapi_context. * - encoding: unused * - decoding: Set by user diff --git a/libavcodec/dca.c b/libavcodec/dca.c index e3c64660db..525832f802 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -1798,7 +1798,7 @@ static int dca_decode_frame(AVCodecContext * avctx, /* There is nothing that prevents a dts frame to change channel configuration - but FFmpeg doesn't support that so only set the channels if it is previously + but Libav doesn't support that so only set the channels if it is previously unset. Ideally during the first probe for channels the crc should be checked and only set avctx->channels when the crc is ok. Right now the decoder could set the channels based on a broken first frame.*/ From 3a50894eaaad3d5a7ec9bad99c08ecb8305c51c1 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 23 Apr 2011 16:40:01 +0200 Subject: [PATCH 140/172] Refer to ff* tools by their lowercase names. --- doc/faq.texi | 4 ++-- doc/ffmpeg.texi | 26 ++++++++++++-------------- doc/ffprobe.texi | 6 +++--- doc/ffserver.texi | 12 ++++++------ 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/doc/faq.texi b/doc/faq.texi index a29af1e1ad..3d7a275f89 100644 --- a/doc/faq.texi +++ b/doc/faq.texi @@ -280,7 +280,7 @@ Just create an "input.avs" text file with this single line ... @example DirectShowSource("C:\path to your file\yourfile.asf") @end example -... and then feed that text file to FFmpeg: +... and then feed that text file to ffmpeg: @example ffmpeg -i input.avs @end example @@ -348,7 +348,7 @@ ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \ rm temp[12].[av] all.[av] @end example -@section FFmpeg does not adhere to the -maxrate setting, some frames are bigger than maxrate/fps. +@section The ffmpeg program does not respect the -maxrate setting, some frames are bigger than maxrate/fps. Read the MPEG spec about video buffer verifier. diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 38da9186e6..62282b2dd0 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -22,17 +22,15 @@ ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{ @chapter Description @c man begin DESCRIPTION -FFmpeg is a very fast video and audio converter. It can also grab from -a live audio/video source. +ffmpeg is a very fast video and audio converter that can also grab from +a live audio/video source. It can also convert between arbitrary sample +rates and resize video on the fly with a high quality polyphase filter. The command line interface is designed to be intuitive, in the sense -that FFmpeg tries to figure out all parameters that can possibly be +that ffmpeg tries to figure out all parameters that can possibly be derived automatically. You usually only have to specify the target bitrate you want. -FFmpeg can also convert from any sample rate to any other, and resize -video on the fly with a high quality polyphase filter. - As a general rule, options are applied to the next specified file. Therefore, order is important, and you can have the same option on the command line multiple times. Each occurrence is @@ -61,7 +59,7 @@ ffmpeg -r 1 -i input.m2v -r 24 output.avi The format option may be needed for raw input files. -By default, FFmpeg tries to convert as losslessly as possible: It +By default ffmpeg tries to convert as losslessly as possible: It uses the same audio and video parameters for the outputs as the one specified for the inputs. @@ -486,7 +484,7 @@ Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4). macroblock decision @table @samp @item 0 -FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in FFmpeg). +FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in ffmpeg). @item 1 FF_MB_DECISION_BITS: Choose the one which needs the fewest bits. @item 2 @@ -868,22 +866,22 @@ It allows almost lossless encoding. @section Video and Audio grabbing -FFmpeg can grab video and audio from devices given that you specify the input -format and device. +If you specify the input format and device then ffmpeg can grab video +and audio directly. @example ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg @end example Note that you must activate the right video source and channel before -launching FFmpeg with any TV viewer such as xawtv +launching ffmpeg with any TV viewer such as xawtv (@url{http://linux.bytesex.org/xawtv/}) by Gerd Knorr. You also have to set the audio recording levels correctly with a standard mixer. @section X11 grabbing -FFmpeg can grab the X11 display. +Grab the X11 display with ffmpeg via @example ffmpeg -f x11grab -s cif -r 25 -i :0.0 /tmp/out.mpg @@ -901,7 +899,7 @@ variable. 10 is the x-offset and 20 the y-offset for the grabbing. @section Video and Audio file format conversion -FFmpeg can use any supported file format and protocol as input: +Any supported file format and protocol can serve as input to ffmpeg: Examples: @itemize @@ -921,7 +919,7 @@ It will use the files: The Y files use twice the resolution of the U and V files. They are raw files, without header. They can be generated by all decent video decoders. You must specify the size of the image with the @option{-s} option -if FFmpeg cannot guess it. +if ffmpeg cannot guess it. @item You can input from a raw YUV420P file: diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi index b775f558dd..15090220f3 100644 --- a/doc/ffprobe.texi +++ b/doc/ffprobe.texi @@ -22,7 +22,7 @@ ffprobe [options] [@file{input_file}] @chapter Description @c man begin DESCRIPTION -FFprobe gathers information from multimedia streams and prints it in +ffprobe gathers information from multimedia streams and prints it in human- and machine-readable fashion. For example it can be used to check the format of the container used @@ -33,7 +33,7 @@ If a filename is specified in input, ffprobe will try to open and probe the file content. If the file cannot be opened or recognized as a multimedia file, a positive exit code is returned. -FFprobe may be employed both as a standalone application or in +ffprobe may be employed both as a standalone application or in combination with a textual filter, which may perform more sophisticated processing, e.g. statistical processing or plotting. @@ -41,7 +41,7 @@ Options are used to list some of the formats supported by ffprobe or for specifying which information to display, and for setting how ffprobe will show it. -FFprobe output is designed to be easily parsable by a textual filter, +ffprobe output is designed to be easily parsable by a textual filter, and consists of one or more sections of the form: @example [SECTION] diff --git a/doc/ffserver.texi b/doc/ffserver.texi index 021b237de5..e5c9d40235 100644 --- a/doc/ffserver.texi +++ b/doc/ffserver.texi @@ -22,12 +22,12 @@ ffserver [options] @chapter Description @c man begin DESCRIPTION -FFserver is a streaming server for both audio and video. It supports +ffserver is a streaming server for both audio and video. It supports several live feeds, streaming from files and time shifting on live feeds (you can seek to positions in the past on each live feed, provided you specify a big enough feed storage in ffserver.conf). -FFserver runs in daemon mode by default; that is, it puts itself in +ffserver runs in daemon mode by default; that is, it puts itself in the background and detaches from its TTY, unless it is launched in debug mode or a NoDaemon option is specified in the configuration file. @@ -39,7 +39,7 @@ information. @section How does it work? -FFserver receives prerecorded files or FFM streams from some ffmpeg +ffserver receives prerecorded files or FFM streams from some ffmpeg instance as input, then streams them over RTP/RTSP/HTTP. An ffserver instance will listen on some port as specified in the @@ -57,7 +57,7 @@ file. @section Status stream -FFserver supports an HTTP interface which exposes the current status +ffserver supports an HTTP interface which exposes the current status of the server. Simply point your browser to the address of the special status stream @@ -249,8 +249,8 @@ For example: @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}. Use @file{configfile} instead of @file{/etc/ffserver.conf}. @item -n Enable no-launch mode. This option disables all the Launch directives -within the various sections. FFserver will not launch any -ffmpeg instance, so you will have to launch them manually. +within the various sections. Since ffserver will not launch +any ffmpeg instances, you will have to launch them manually. @item -d Enable debug mode. This option increases log verbosity, directs log messages to stdout and causes ffserver to run in the foreground From 89b503b55f2b2713f1c3cc8981102c1a7b663281 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 23 Apr 2011 15:19:17 +0200 Subject: [PATCH 141/172] Lowercase all ff* program names. --- doc/ffmpeg.texi | 6 +++--- doc/ffplay.texi | 4 ++-- doc/ffprobe.texi | 6 +++--- doc/ffserver.texi | 6 +++--- ffmpeg.c | 4 ++-- ffplay.c | 4 ++-- ffprobe.c | 4 ++-- ffserver.c | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 62282b2dd0..0d12f65f02 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1,8 +1,8 @@ \input texinfo @c -*- texinfo -*- -@settitle FFmpeg Documentation +@settitle ffmpeg Documentation @titlepage -@center @titlefont{FFmpeg Documentation} +@center @titlefont{ffmpeg Documentation} @end titlepage @top @@ -1046,7 +1046,7 @@ file to which you want to add them. @ignore @setfilename ffmpeg -@settitle FFmpeg video converter +@settitle ffmpeg video converter @c man begin SEEALSO ffplay(1), ffprobe(1), ffserver(1) and the Libav HTML documentation diff --git a/doc/ffplay.texi b/doc/ffplay.texi index 6199e6d269..e5de3d2d6d 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -1,8 +1,8 @@ \input texinfo @c -*- texinfo -*- -@settitle FFplay Documentation +@settitle ffplay Documentation @titlepage -@center @titlefont{FFplay Documentation} +@center @titlefont{ffplay Documentation} @end titlepage @top diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi index 15090220f3..5e856e6645 100644 --- a/doc/ffprobe.texi +++ b/doc/ffprobe.texi @@ -1,8 +1,8 @@ \input texinfo @c -*- texinfo -*- -@settitle FFprobe Documentation +@settitle ffprobe Documentation @titlepage -@center @titlefont{FFprobe Documentation} +@center @titlefont{ffprobe Documentation} @end titlepage @top @@ -119,7 +119,7 @@ with name "STREAM". @ignore @setfilename ffprobe -@settitle FFprobe media prober +@settitle ffprobe media prober @c man begin SEEALSO ffmpeg(1), ffplay(1), ffserver(1) and the Libav HTML documentation diff --git a/doc/ffserver.texi b/doc/ffserver.texi index e5c9d40235..d247016bbc 100644 --- a/doc/ffserver.texi +++ b/doc/ffserver.texi @@ -1,8 +1,8 @@ \input texinfo @c -*- texinfo -*- -@settitle FFserver Documentation +@settitle ffserver Documentation @titlepage -@center @titlefont{FFserver Documentation} +@center @titlefont{ffserver Documentation} @end titlepage @top @@ -261,7 +261,7 @@ rather than as a daemon. @ignore @setfilename ffserver -@settitle FFserver video server +@settitle ffserver video server @c man begin SEEALSO diff --git a/ffmpeg.c b/ffmpeg.c index 886d5da7de..d54785d597 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1,5 +1,5 @@ /* - * FFmpeg main + * ffmpeg main * Copyright (c) 2000-2003 Fabrice Bellard * * This file is part of Libav. @@ -78,7 +78,7 @@ #include "libavutil/avassert.h" -const char program_name[] = "FFmpeg"; +const char program_name[] = "ffmpeg"; const int program_birth_year = 2000; /* select an input stream for an output stream */ diff --git a/ffplay.c b/ffplay.c index 766d5caf9c..18010ef076 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1,5 +1,5 @@ /* - * FFplay : Simple Media Player based on the Libav libraries + * ffplay : Simple Media Player based on the Libav libraries * Copyright (c) 2003 Fabrice Bellard * * This file is part of Libav. @@ -55,7 +55,7 @@ #include #include -const char program_name[] = "FFplay"; +const char program_name[] = "ffplay"; const int program_birth_year = 2003; //#define DEBUG diff --git a/ffprobe.c b/ffprobe.c index cc3699bf9b..6e26c115a7 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1,5 +1,5 @@ /* - * FFprobe : Simple Media Prober based on the Libav libraries + * ffprobe : Simple Media Prober based on the Libav libraries * Copyright (c) 2007-2010 Stefano Sabatini * * This file is part of Libav. @@ -28,7 +28,7 @@ #include "libavdevice/avdevice.h" #include "cmdutils.h" -const char program_name[] = "FFprobe"; +const char program_name[] = "ffprobe"; const int program_birth_year = 2007; static int do_show_format = 0; diff --git a/ffserver.c b/ffserver.c index 9cb65da017..829eb2ef7e 100644 --- a/ffserver.c +++ b/ffserver.c @@ -59,7 +59,7 @@ #include "cmdutils.h" -const char program_name[] = "FFserver"; +const char program_name[] = "ffserver"; const int program_birth_year = 2000; static const OptionDef options[]; From c225615bf2da206775c5ff2b56d648cf50d38756 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Sat, 23 Apr 2011 12:41:11 -0700 Subject: [PATCH 142/172] In libx264 wrapper, fix side effect with has_b_frames, bframe_pyramid can be set when bframe is not. --- libavcodec/libx264.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index acd13668d7..1b4e88b75b 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -366,7 +366,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.b_repeat_headers = 0; // update AVCodecContext with x264 parameters - avctx->has_b_frames = x4->params.i_bframe_pyramid ? 2 : !!x4->params.i_bframe; + avctx->has_b_frames = x4->params.i_bframe ? + x4->params.i_bframe_pyramid ? 2 : 1 : 0; avctx->bit_rate = x4->params.rc.i_bitrate*1000; avctx->crf = x4->params.rc.f_rf_constant; From 9261e6cf3fe579fa02a96761c8e81a77bb3d8b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 20 Apr 2011 15:36:37 +0300 Subject: [PATCH 143/172] rtp: Rename the open/close functions to alloc/free MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids clashes if we internally want to override the global open function. Signed-off-by: Martin Storsjö --- libavformat/rdt.c | 4 ++-- libavformat/rtpdec.h | 4 ++-- libavformat/rtpdec_amr.c | 8 ++++---- libavformat/rtpdec_asf.c | 4 ++-- libavformat/rtpdec_h264.c | 4 ++-- libavformat/rtpdec_latm.c | 4 ++-- libavformat/rtpdec_mpeg4.c | 8 ++++---- libavformat/rtpdec_qcelp.c | 4 ++-- libavformat/rtpdec_qdm2.c | 4 ++-- libavformat/rtpdec_qt.c | 4 ++-- libavformat/rtpdec_svq3.c | 4 ++-- libavformat/rtpdec_vp8.c | 4 ++-- libavformat/rtpdec_xiph.c | 8 ++++---- libavformat/rtsp.c | 6 +++--- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/libavformat/rdt.c b/libavformat/rdt.c index dfb31d15f0..bc3c17bd0d 100644 --- a/libavformat/rdt.c +++ b/libavformat/rdt.c @@ -551,8 +551,8 @@ static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \ .codec_type = t, \ .codec_id = CODEC_ID_NONE, \ .parse_sdp_a_line = rdt_parse_sdp_line, \ - .open = rdt_new_context, \ - .close = rdt_free_context, \ + .alloc = rdt_new_context, \ + .free = rdt_free_context, \ .parse_packet = rdt_parse_packet \ } diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h index da53efc1f4..a4d21aa688 100644 --- a/libavformat/rtpdec.h +++ b/libavformat/rtpdec.h @@ -126,8 +126,8 @@ struct RTPDynamicProtocolHandler_s { int st_index, PayloadContext *priv_data, const char *line); ///< Parse the a= line from the sdp field - PayloadContext *(*open) (void); ///< allocate any data needed by the rtp parsing for this dynamic data. - void (*close)(PayloadContext *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data. + PayloadContext *(*alloc) (void); ///< allocate any data needed by the rtp parsing for this dynamic data. + void (*free)(PayloadContext *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data. DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet. struct RTPDynamicProtocolHandler_s *next; diff --git a/libavformat/rtpdec_amr.c b/libavformat/rtpdec_amr.c index 802e7c1ce8..b7ff3aa05e 100644 --- a/libavformat/rtpdec_amr.c +++ b/libavformat/rtpdec_amr.c @@ -191,8 +191,8 @@ RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_AMR_NB, .parse_sdp_a_line = amr_parse_sdp_line, - .open = amr_new_context, - .close = amr_free_context, + .alloc = amr_new_context, + .free = amr_free_context, .parse_packet = amr_handle_packet, }; @@ -201,8 +201,8 @@ RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_AMR_WB, .parse_sdp_a_line = amr_parse_sdp_line, - .open = amr_new_context, - .close = amr_free_context, + .alloc = amr_new_context, + .free = amr_free_context, .parse_packet = amr_handle_packet, }; diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index a8326cf123..ecacc0eb4e 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -286,8 +286,8 @@ RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \ .codec_type = t, \ .codec_id = CODEC_ID_NONE, \ .parse_sdp_a_line = asfrtp_parse_sdp_line, \ - .open = asfrtp_new_context, \ - .close = asfrtp_free_context, \ + .alloc = asfrtp_new_context, \ + .free = asfrtp_free_context, \ .parse_packet = asfrtp_parse_packet, \ } diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c index 4c9b8ba0bd..effdc1fe66 100644 --- a/libavformat/rtpdec_h264.c +++ b/libavformat/rtpdec_h264.c @@ -398,7 +398,7 @@ RTPDynamicProtocolHandler ff_h264_dynamic_handler = { .codec_type = AVMEDIA_TYPE_VIDEO, .codec_id = CODEC_ID_H264, .parse_sdp_a_line = parse_h264_sdp_line, - .open = h264_new_context, - .close = h264_free_context, + .alloc = h264_new_context, + .free = h264_free_context, .parse_packet = h264_handle_packet }; diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index 5bf4c1964e..bde34b7ab9 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -181,7 +181,7 @@ RTPDynamicProtocolHandler ff_mp4a_latm_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_AAC, .parse_sdp_a_line = latm_parse_sdp_line, - .open = latm_new_context, - .close = latm_free_context, + .alloc = latm_new_context, + .free = latm_free_context, .parse_packet = latm_parse_packet }; diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c index 9f2fcb3dbc..7a63cc315b 100644 --- a/libavformat/rtpdec_mpeg4.c +++ b/libavformat/rtpdec_mpeg4.c @@ -235,8 +235,8 @@ RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler = { .codec_type = AVMEDIA_TYPE_VIDEO, .codec_id = CODEC_ID_MPEG4, .parse_sdp_a_line = parse_sdp_line, - .open = NULL, - .close = NULL, + .alloc = NULL, + .free = NULL, .parse_packet = NULL }; @@ -245,7 +245,7 @@ RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_AAC, .parse_sdp_a_line = parse_sdp_line, - .open = new_context, - .close = free_context, + .alloc = new_context, + .free = free_context, .parse_packet = aac_parse_packet }; diff --git a/libavformat/rtpdec_qcelp.c b/libavformat/rtpdec_qcelp.c index cc16ec1f7f..325683c396 100644 --- a/libavformat/rtpdec_qcelp.c +++ b/libavformat/rtpdec_qcelp.c @@ -223,7 +223,7 @@ RTPDynamicProtocolHandler ff_qcelp_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_QCELP, .static_payload_id = 12, - .open = qcelp_new_context, - .close = qcelp_free_context, + .alloc = qcelp_new_context, + .free = qcelp_free_context, .parse_packet = qcelp_parse_packet }; diff --git a/libavformat/rtpdec_qdm2.c b/libavformat/rtpdec_qdm2.c index 0d744be820..7f5f0771bc 100644 --- a/libavformat/rtpdec_qdm2.c +++ b/libavformat/rtpdec_qdm2.c @@ -309,7 +309,7 @@ RTPDynamicProtocolHandler ff_qdm2_dynamic_handler = { .enc_name = "X-QDM", .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_NONE, - .open = qdm2_extradata_new, - .close = qdm2_extradata_free, + .alloc = qdm2_extradata_new, + .free = qdm2_extradata_free, .parse_packet = qdm2_parse_packet, }; diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c index a295ba7381..8dd2968398 100644 --- a/libavformat/rtpdec_qt.c +++ b/libavformat/rtpdec_qt.c @@ -244,8 +244,8 @@ RTPDynamicProtocolHandler ff_ ## m ## _rtp_ ## n ## _handler = { \ .enc_name = s, \ .codec_type = t, \ .codec_id = CODEC_ID_NONE, \ - .open = qt_rtp_new, \ - .close = qt_rtp_free, \ + .alloc = qt_rtp_new, \ + .free = qt_rtp_free, \ .parse_packet = qt_rtp_parse_packet, \ } diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c index 8c0926212c..331434245e 100644 --- a/libavformat/rtpdec_svq3.c +++ b/libavformat/rtpdec_svq3.c @@ -128,7 +128,7 @@ RTPDynamicProtocolHandler ff_svq3_dynamic_handler = { .enc_name = "X-SV3V-ES", .codec_type = AVMEDIA_TYPE_VIDEO, .codec_id = CODEC_ID_NONE, // see if (config_packet) above - .open = svq3_extradata_new, - .close = svq3_extradata_free, + .alloc = svq3_extradata_new, + .free = svq3_extradata_free, .parse_packet = svq3_parse_packet, }; diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index 9e50cc44e1..026728ec9d 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -148,7 +148,7 @@ RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { .enc_name = "VP8", .codec_type = AVMEDIA_TYPE_VIDEO, .codec_id = CODEC_ID_VP8, - .open = vp8_new_context, - .close = vp8_free_context, + .alloc = vp8_new_context, + .free = vp8_free_context, .parse_packet = vp8_handle_packet, }; diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c index 4d8e834813..a7f36ef59a 100644 --- a/libavformat/rtpdec_xiph.c +++ b/libavformat/rtpdec_xiph.c @@ -389,8 +389,8 @@ RTPDynamicProtocolHandler ff_theora_dynamic_handler = { .codec_type = AVMEDIA_TYPE_VIDEO, .codec_id = CODEC_ID_THEORA, .parse_sdp_a_line = xiph_parse_sdp_line, - .open = xiph_new_context, - .close = xiph_free_context, + .alloc = xiph_new_context, + .free = xiph_free_context, .parse_packet = xiph_handle_packet }; @@ -399,7 +399,7 @@ RTPDynamicProtocolHandler ff_vorbis_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_VORBIS, .parse_sdp_a_line = xiph_parse_sdp_line, - .open = xiph_new_context, - .close = xiph_free_context, + .alloc = xiph_new_context, + .free = xiph_free_context, .parse_packet = xiph_handle_packet }; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 58f7ddc1a6..14111e69fd 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -132,8 +132,8 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler, return; codec->codec_id = handler->codec_id; rtsp_st->dynamic_handler = handler; - if (handler->open) - rtsp_st->dynamic_protocol_context = handler->open(); + if (handler->alloc) + rtsp_st->dynamic_protocol_context = handler->alloc(); } /* parse the rtpmap description: /[/] */ @@ -526,7 +526,7 @@ void ff_rtsp_close_streams(AVFormatContext *s) rtsp_st = rt->rtsp_streams[i]; if (rtsp_st) { if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) - rtsp_st->dynamic_handler->close( + rtsp_st->dynamic_handler->free( rtsp_st->dynamic_protocol_context); av_free(rtsp_st); } From b1ac139d89b9fc55b70ad3411af2f75fe8b17805 Mon Sep 17 00:00:00 2001 From: Kirill Gavrilov Date: Wed, 20 Apr 2011 14:36:44 +0300 Subject: [PATCH 144/172] Handle unicode file names on windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All file names should be in UTF-8 within libavformat. This is handled by mapping the open() function to an internal one in os_support.h for windows. fopen() could be overridden in the same way, but if that would be used from ffmpeg.c, it would add a dependency on an ff prefixed internal lavf function. Signed-off-by: Martin Storsjö --- cmdutils.c | 63 ++++++++++++++++++++++++++++++++++++++++ libavformat/os_support.c | 28 ++++++++++++++++++ libavformat/os_support.h | 5 ++++ libavformat/version.h | 2 +- 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/cmdutils.c b/cmdutils.c index f1cbd55373..f25f61d4e5 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -155,6 +155,66 @@ static const OptionDef* find_option(const OptionDef *po, const char *name){ return po; } +#if defined(_WIN32) && !defined(__MINGW32CE__) +/* Will be leaked on exit */ +static char** win32_argv_utf8 = NULL; +static int win32_argc = 0; + +/** + * Prepare command line arguments for executable. + * For Windows - perform wide-char to UTF-8 conversion. + * Input arguments should be main() function arguments. + * @param argc_ptr Arguments number (including executable) + * @param argv_ptr Arguments list. + */ +static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) +{ + char *argstr_flat; + wchar_t **argv_w; + int i, buffsize = 0, offset = 0; + + if (win32_argv_utf8) { + *argc_ptr = win32_argc; + *argv_ptr = win32_argv_utf8; + return; + } + + win32_argc = 0; + argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc); + if (win32_argc <= 0 || !argv_w) + return; + + /* determine the UTF-8 buffer size (including NULL-termination symbols) */ + for (i = 0; i < win32_argc; i++) + buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, + NULL, 0, NULL, NULL); + + win32_argv_utf8 = av_mallocz(sizeof(char*) * (win32_argc + 1) + buffsize); + argstr_flat = (char*)win32_argv_utf8 + sizeof(char*) * (win32_argc + 1); + if (win32_argv_utf8 == NULL) { + LocalFree(argv_w); + return; + } + + for (i = 0; i < win32_argc; i++) { + win32_argv_utf8[i] = &argstr_flat[offset]; + offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, + &argstr_flat[offset], + buffsize - offset, NULL, NULL); + } + win32_argv_utf8[i] = NULL; + LocalFree(argv_w); + + *argc_ptr = win32_argc; + *argv_ptr = win32_argv_utf8; +} +#else +static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) +{ + /* nothing to do */ +} +#endif /* WIN32 && !__MINGW32CE__ */ + void parse_options(int argc, char **argv, const OptionDef *options, void (* parse_arg_function)(const char*)) { @@ -162,6 +222,9 @@ void parse_options(int argc, char **argv, const OptionDef *options, int optindex, handleoptions=1; const OptionDef *po; + /* perform system-dependent conversions for arguments list */ + prepare_app_arguments(&argc, &argv); + /* parse options */ optindex = 1; while (optindex < argc) { diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 5a3a1bbfe0..05577b7553 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -28,6 +28,34 @@ #include "avformat.h" #include "os_support.h" +#if defined(_WIN32) && !defined(__MINGW32CE__) +#include + +#undef open +int ff_win32_open(const char *filename_utf8, int oflag, int pmode) +{ + int fd; + int num_chars; + wchar_t *filename_w; + + /* convert UTF-8 to wide chars */ + num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, NULL, 0); + if (num_chars <= 0) + return -1; + filename_w = av_mallocz(sizeof(wchar_t) * num_chars); + MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars); + + fd = _wopen(filename_w, oflag, pmode); + av_freep(&filename_w); + + /* filename maybe be in CP_ACP */ + if (fd == -1 && !(oflag & O_CREAT)) + return open(filename_utf8, oflag, pmode); + + return fd; +} +#endif + #if CONFIG_NETWORK #include #include diff --git a/libavformat/os_support.h b/libavformat/os_support.h index dc01e6413c..521e9978a2 100644 --- a/libavformat/os_support.h +++ b/libavformat/os_support.h @@ -45,6 +45,11 @@ static inline int is_dos_path(const char *path) return 0; } +#if defined(_WIN32) && !defined(__MINGW32CE__) +int ff_win32_open(const char *filename, int oflag, int pmode); +#define open ff_win32_open +#endif + #if CONFIG_NETWORK #if !HAVE_SOCKLEN_T typedef int socklen_t; diff --git a/libavformat/version.h b/libavformat/version.h index 9041f92626..22b5dc9791 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -25,7 +25,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 53 #define LIBAVFORMAT_VERSION_MINOR 0 -#define LIBAVFORMAT_VERSION_MICRO 2 +#define LIBAVFORMAT_VERSION_MICRO 3 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From b678d6db95b3f7304db6e01f26807fb23e2e7d0e Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Sat, 23 Apr 2011 22:08:48 +1000 Subject: [PATCH 145/172] permit decoding of multichannel ADPCM_EA_XAS Signed-off-by: Michael Niedermayer --- libavcodec/adpcm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 6252dbcb6a..c1ceca918a 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -750,6 +750,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: + case CODEC_ID_ADPCM_EA_XAS: max_channels = 6; break; } From c8a5e8a8948bcd7c0d01d3f64d58c1dc7e29d4e2 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Sun, 24 Apr 2011 09:41:51 +1000 Subject: [PATCH 146/172] EA cdata demuxer: set codec->sample_fmt This is required by has_codec_parameters in libavformat/utils.c Signed-off-by: Michael Niedermayer --- libavformat/eacdata.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c index 7b109ff888..7cdd6ff22d 100644 --- a/libavformat/eacdata.c +++ b/libavformat/eacdata.c @@ -72,6 +72,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_id = CODEC_ID_ADPCM_EA_XAS; st->codec->channels = cdata->channels; st->codec->sample_rate = sample_rate; + st->codec->sample_fmt = AV_SAMPLE_FMT_S16; av_set_pts_info(st, 64, 1, sample_rate); cdata->audio_pts = 0; From db62d898330664a9b69ba5a1feee18338bb00852 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Sat, 23 Apr 2011 22:09:10 +1000 Subject: [PATCH 147/172] EA cdata demuxer: support 6 channel files Signed-off-by: Michael Niedermayer --- libavformat/eacdata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c index 7cdd6ff22d..b00137582c 100644 --- a/libavformat/eacdata.c +++ b/libavformat/eacdata.c @@ -39,7 +39,7 @@ static int cdata_probe(AVProbeData *p) { const uint8_t *b = p->buf; - if (b[0] == 0x04 && (b[1] == 0x00 || b[1] == 0x04 || b[1] == 0x0C)) + if (b[0] == 0x04 && (b[1] == 0x00 || b[1] == 0x04 || b[1] == 0x0C || b[1] == 0x14)) return AVPROBE_SCORE_MAX/8; return 0; } @@ -56,6 +56,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap) case 0x0400: cdata->channels = 1; break; case 0x0404: cdata->channels = 2; break; case 0x040C: cdata->channels = 4; break; + case 0x0414: cdata->channels = 6; break; default: av_log(s, AV_LOG_INFO, "unknown header 0x%04x\n", header); return -1; From c2a8f125855aef72efcde8a06dd73a5fbe5dcf25 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Sat, 23 Apr 2011 22:09:19 +1000 Subject: [PATCH 148/172] EA cdata demuxer: support files with 20 byte header Signed-off-by: Michael Niedermayer --- libavformat/eacdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c index b00137582c..c8999c6b23 100644 --- a/libavformat/eacdata.c +++ b/libavformat/eacdata.c @@ -63,7 +63,7 @@ static int cdata_read_header(AVFormatContext *s, AVFormatParameters *ap) }; sample_rate = avio_rb16(pb); - avio_skip(pb, 12); + avio_skip(pb, (avio_r8(pb) & 0x20) ? 15 : 11); st = av_new_stream(s, 0); if (!st) From 183132872a1d8bc8a32e7fd8f994fa2f1b2d6bfc Mon Sep 17 00:00:00 2001 From: Sebastian Vater Date: Wed, 20 Apr 2011 13:56:56 +0200 Subject: [PATCH 149/172] HAM6/HAM8 support for IFF demuxer/decoder Signed-off-by: Michael Niedermayer --- libavcodec/iff.c | 276 +++++++++++++++++++++++++++++++++++++++++++--- libavformat/iff.c | 78 +++++++++++-- 2 files changed, 333 insertions(+), 21 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index e64ce1eeb6..2467781537 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -30,10 +30,72 @@ #include "avcodec.h" #include "get_bits.h" +// TODO: masking bits +typedef enum { + MASK_NONE, + MASK_HAS_MASK, + MASK_HAS_TRANSPARENT_COLOR, + MASK_LASSO +} mask_type; + +/** + * Gets the actual extra data after video preperties which contains + * the raw CMAP palette data beyond the IFF extra context. + * + * @param avctx the AVCodecContext where to extract raw palette data from + * @return pointer to raw CMAP palette data + */ +static av_always_inline uint8_t *get_palette_data(const AVCodecContext *const avctx) { + return avctx->extradata + AV_RB16(avctx->extradata); +} + +/** + * Gets the size of CMAP palette data beyond the IFF extra context. + * Please note that any value < 2 of IFF extra context or + * raw extradata < 0 is considered as illegal extradata. + * + * @param avctx the AVCodecContext where to extract palette data size from + * @return size of raw palette data in bytes + */ +static av_always_inline int get_palette_size(const AVCodecContext *const avctx) { + return avctx->extradata_size - AV_RB16(avctx->extradata); +} + +/** + * Gets the actual raw image data after video properties which + * contains the raw image data beyond the IFF extra context. + * + * @param avpkt the AVPacket where to extract raw image data from + * @return pointer to raw image data + */ +static av_always_inline uint8_t *get_image_data(const AVPacket *const avpkt) { + return avpkt->data + AV_RB16(avpkt->data); +} + +/** + * Gets the size of raw image data beyond the IFF extra context. + * Please note that any value < 2 of either IFF extra context + * or raw image data is considered as an illegal packet. + * + * @param avpkt the AVPacket where to extract image data size from + * @return size of raw image data in bytes + */ +static av_always_inline int get_image_size(const AVPacket *const avpkt) { + return avpkt->size - AV_RB16(avpkt->data); +} + typedef struct { AVFrame frame; int planesize; uint8_t * planebuf; + uint8_t * ham_buf; ///< temporary buffer for planar to chunky conversation + uint32_t *ham_palbuf; ///< HAM decode table + unsigned compression; ///< delta compression method used + unsigned bpp; ///< bits per plane to decode (differs from bits_per_coded_sample if HAM) + unsigned ham; ///< 0 if non-HAM or number of hold bits (6 for bpp > 6, 4 otherwise) + unsigned flags; ///< 1 for EHB, 0 is no extra half darkening + unsigned transparency; ///< TODO: transparency color index in palette + unsigned masking; ///< TODO: masking method used int init; // 1 if buffer and palette data already initialized, 0 otherwise } IffContext; @@ -122,6 +184,7 @@ static av_always_inline uint32_t gray2rgb(const uint32_t x) { static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) { int count, i; + const uint8_t *const extradata = get_palette_data(avctx); if (avctx->bits_per_coded_sample > 8) { av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n"); @@ -130,10 +193,10 @@ static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) count = 1 << avctx->bits_per_coded_sample; // If extradata is smaller than actually needed, fill the remaining with black. - count = FFMIN(avctx->extradata_size / 3, count); + count = FFMIN(get_palette_size(avctx) / 3, count); if (count) { for (i=0; i < count; i++) { - pal[i] = 0xFF000000 | AV_RB24( avctx->extradata + i*3 ); + pal[i] = 0xFF000000 | AV_RB24(extradata + i*3); } } else { // Create gray-scale color palette for bps < 8 count = 1 << avctx->bits_per_coded_sample; @@ -145,15 +208,123 @@ static int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) return 0; } +/** + * Extracts the IFF extra context and updates internal + * decoder structures. + * + * @param avctx the AVCodecContext where to extract extra context to + * @param avpkt the AVPacket to extract extra context from or NULL to use avctx + * @return 0 in case of success, a negative error code otherwise + */ +static int extract_header(AVCodecContext *const avctx, + const AVPacket *const avpkt) { + const uint8_t *buf; + unsigned buf_size; + IffContext *s = avctx->priv_data; + if (avpkt) { + if (avpkt->size < 2) + return AVERROR_INVALIDDATA; + buf = avpkt->data; + buf_size = bytestream_get_be16(&buf); + if (buf_size <= 1 || get_image_size(avpkt) <= 1) { + av_log(avctx, AV_LOG_ERROR, + "Invalid image size received: %u -> image data offset: %d\n", + buf_size, get_image_size(avpkt)); + return AVERROR_INVALIDDATA; + } + } else { + if (avctx->extradata_size < 2) + return AVERROR_INVALIDDATA; + buf = avctx->extradata; + buf_size = bytestream_get_be16(&buf); + if (buf_size <= 1 || get_palette_size(avctx) < 0) { + av_log(avctx, AV_LOG_ERROR, + "Invalid palette size received: %u -> palette data offset: %d\n", + buf_size, get_palette_size(avctx)); + return AVERROR_INVALIDDATA; + } + } + + if (buf_size > 8) { + s->compression = bytestream_get_byte(&buf); + s->bpp = bytestream_get_byte(&buf); + s->ham = bytestream_get_byte(&buf); + s->flags = bytestream_get_byte(&buf); + s->transparency = bytestream_get_be16(&buf); + s->masking = bytestream_get_byte(&buf); + if (s->masking == MASK_HAS_TRANSPARENT_COLOR) { + av_log(avctx, AV_LOG_ERROR, "Transparency not supported\n"); + return AVERROR_PATCHWELCOME; + } else if (s->masking != MASK_NONE) { + av_log(avctx, AV_LOG_ERROR, "Masking not supported\n"); + return AVERROR_PATCHWELCOME; + } + if (!s->bpp || s->bpp > 32) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", s->bpp); + return AVERROR_INVALIDDATA; + } else if (s->ham >= 8) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: %u\n", s->ham); + return AVERROR_INVALIDDATA; + } + + av_freep(&s->ham_buf); + av_freep(&s->ham_palbuf); + + if (s->ham) { + int i, count = FFMIN(get_palette_size(avctx) / 3, 1 << s->ham); + const uint8_t *const extradata = get_palette_data(avctx); + s->ham_buf = av_malloc((s->planesize * 8) + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->ham_buf) + return AVERROR(ENOMEM); + + s->ham_palbuf = av_malloc((8 * (1 << s->ham) * sizeof (uint32_t)) + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->ham_palbuf) { + av_freep(&s->ham_buf); + return AVERROR(ENOMEM); + } + + if (count) { // HAM with color palette attached + // prefill with black and palette and set HAM take direct value mask to zero + memset(s->ham_palbuf, 0, (1 << s->ham) * 2 * sizeof (uint32_t)); + for (i=0; i < count; i++) { + s->ham_palbuf[i*2+1] = AV_RL24(extradata + i*3); + } + count = 1 << s->ham; + } else { // HAM with grayscale color palette + count = 1 << s->ham; + for (i=0; i < count; i++) { + s->ham_palbuf[i*2] = 0; // take direct color value from palette + s->ham_palbuf[i*2+1] = av_le2ne32(gray2rgb((i * 255) >> s->ham)); + } + } + for (i=0; i < count; i++) { + uint32_t tmp = i << (8 - s->ham); + tmp |= tmp >> s->ham; + s->ham_palbuf[(i+count)*2] = 0x00FFFF; // just modify blue color component + s->ham_palbuf[(i+count*2)*2] = 0xFFFF00; // just modify red color component + s->ham_palbuf[(i+count*3)*2] = 0xFF00FF; // just modify green color component + s->ham_palbuf[(i+count)*2+1] = tmp << 16; + s->ham_palbuf[(i+count*2)*2+1] = tmp; + s->ham_palbuf[(i+count*3)*2+1] = tmp << 8; + } + } else if (s->flags & 1) { // EHB (ExtraHalfBrite) color palette + av_log(avctx, AV_LOG_ERROR, "ExtraHalfBrite (EHB) mode not supported\n"); + return AVERROR_PATCHWELCOME; + } + } + + return 0; +} + static av_cold int decode_init(AVCodecContext *avctx) { IffContext *s = avctx->priv_data; int err; if (avctx->bits_per_coded_sample <= 8) { - avctx->pix_fmt = (avctx->bits_per_coded_sample < 8 || - avctx->extradata_size) ? PIX_FMT_PAL8 - : PIX_FMT_GRAY8; + avctx->pix_fmt = (avctx->bits_per_coded_sample < 8) || + (avctx->extradata_size >= 2 && get_palette_size(avctx)) ? PIX_FMT_PAL8 + : PIX_FMT_GRAY8; } else if (avctx->bits_per_coded_sample <= 32) { avctx->pix_fmt = PIX_FMT_BGR32; } else { @@ -167,6 +338,10 @@ static av_cold int decode_init(AVCodecContext *avctx) if (!s->planebuf) return AVERROR(ENOMEM); + s->bpp = avctx->bits_per_coded_sample; + + if ((err = extract_header(avctx, NULL)) < 0) + return err; s->frame.reference = 1; return 0; @@ -214,6 +389,39 @@ static void decodeplane32(uint32_t *dst, const uint8_t *buf, int buf_size, int p } while (--buf_size); } +#define DECODE_HAM_PLANE32(x) \ + first = buf[x] << 1; \ + second = buf[(x)+1] << 1; \ + delta &= pal[first++]; \ + delta |= pal[first]; \ + dst[x] = delta; \ + delta &= pal[second++]; \ + delta |= pal[second]; \ + dst[(x)+1] = delta + +/** + * Converts one line of HAM6/8-encoded chunky buffer to 24bpp. + * + * @param dst the destination 24bpp buffer + * @param buf the source 8bpp chunky buffer + * @param pal the HAM decode table + * @param buf_size the plane size in bytes + */ +static void decode_ham_plane32(uint32_t *dst, const uint8_t *buf, + const uint32_t *const pal, unsigned buf_size) +{ + uint32_t delta = 0; + do { + uint32_t first, second; + DECODE_HAM_PLANE32(0); + DECODE_HAM_PLANE32(2); + DECODE_HAM_PLANE32(4); + DECODE_HAM_PLANE32(6); + buf += 8; + dst += 8; + } while (--buf_size); +} + /** * Decode one complete byterun1 encoded line. * @@ -250,11 +458,14 @@ static int decode_frame_ilbm(AVCodecContext *avctx, AVPacket *avpkt) { IffContext *s = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + const uint8_t *buf = avpkt->size >= 2 ? get_image_data(avpkt) : NULL; + const int buf_size = avpkt->size >= 2 ? get_image_size(avpkt) : 0; const uint8_t *buf_end = buf+buf_size; int y, plane, res; + if ((res = extract_header(avctx, avpkt)) < 0) + return res; + if (s->init) { if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); @@ -274,16 +485,26 @@ static int decode_frame_ilbm(AVCodecContext *avctx, for(y = 0; y < avctx->height; y++ ) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memset(row, 0, avctx->width); - for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) { + for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), plane); buf += s->planesize; } } + } else if (s->ham) { // HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height; y++) { + uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; + memset(s->ham_buf, 0, avctx->width); + for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { + decodeplane8(s->ham_buf, buf, FFMIN(s->planesize, buf_end - buf), plane); + buf += s->planesize; + } + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); + } } else { // PIX_FMT_BGR32 for(y = 0; y < avctx->height; y++ ) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; memset(row, 0, avctx->width << 2); - for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) { + for (plane = 0; plane < s->bpp && buf < buf_end; plane++) { decodeplane32((uint32_t *) row, buf, FFMIN(s->planesize, buf_end - buf), plane); buf += s->planesize; } @@ -295,6 +516,13 @@ static int decode_frame_ilbm(AVCodecContext *avctx, memcpy(row, buf, FFMIN(avctx->width, buf_end - buf)); buf += avctx->width + (avctx->width % 2); // padding if odd } + } else { // IFF-PBM: HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height; 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 + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, avctx->width); + } } *data_size = sizeof(AVFrame); @@ -307,11 +535,13 @@ static int decode_frame_byterun1(AVCodecContext *avctx, AVPacket *avpkt) { IffContext *s = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + const uint8_t *buf = avpkt->size >= 2 ? get_image_data(avpkt) : NULL; + const int buf_size = avpkt->size >= 2 ? get_image_size(avpkt) : 0; const uint8_t *buf_end = buf+buf_size; int y, plane, res; + if ((res = extract_header(avctx, avpkt)) < 0) + return res; if (s->init) { if ((res = avctx->reget_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); @@ -331,26 +561,42 @@ static int decode_frame_byterun1(AVCodecContext *avctx, for(y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memset(row, 0, avctx->width); - for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) { + for (plane = 0; plane < s->bpp; plane++) { buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); decodeplane8(row, s->planebuf, s->planesize, plane); } } + } else if (s->ham) { // HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height ; y++) { + uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; + memset(s->ham_buf, 0, avctx->width); + for (plane = 0; plane < s->bpp; plane++) { + buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); + decodeplane8(s->ham_buf, s->planebuf, s->planesize, plane); + } + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); + } } else { //PIX_FMT_BGR32 for(y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; memset(row, 0, avctx->width << 2); - for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) { + for (plane = 0; plane < s->bpp; plane++) { buf += decode_byterun(s->planebuf, s->planesize, buf, buf_end); decodeplane32((uint32_t *) row, s->planebuf, s->planesize, plane); } } } - } else { + } else if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) { // IFF-PBM for(y = 0; y < avctx->height ; y++ ) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(row, avctx->width, buf, buf_end); } + } else { // IFF-PBM: HAM to PIX_FMT_BGR32 + for (y = 0; y < avctx->height ; y++) { + uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; + buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end); + decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, avctx->width); + } } *data_size = sizeof(AVFrame); @@ -364,6 +610,8 @@ static av_cold int decode_end(AVCodecContext *avctx) if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); av_freep(&s->planebuf); + av_freep(&s->ham_buf); + av_freep(&s->ham_palbuf); return 0; } diff --git a/libavformat/iff.c b/libavformat/iff.c index 24942122ad..da4e858501 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -29,6 +29,7 @@ * http://wiki.multimedia.cx/index.php?title=IFF */ +#include "libavcodec/bytestream.h" #include "libavutil/intreadwrite.h" #include "avformat.h" @@ -40,6 +41,7 @@ #define ID_PBM MKTAG('P','B','M',' ') #define ID_ILBM MKTAG('I','L','B','M') #define ID_BMHD MKTAG('B','M','H','D') +#define ID_CAMG MKTAG('C','A','M','G') #define ID_CMAP MKTAG('C','M','A','P') #define ID_FORM MKTAG('F','O','R','M') @@ -60,6 +62,16 @@ #define PACKET_SIZE 1024 +/** + * This number of bytes if added at the beginning of each AVPacket + * which contain additional information about video properties + * which has to be shared between demuxer and decoder. + * This number may change between frames, e.g. the demuxer might + * set it to smallest possible size of 2 to indicate that there's + * no extradata changing in this frame. + */ +#define IFF_EXTRA_VIDEO_SIZE 9 + typedef enum { COMP_NONE, COMP_FIB, @@ -76,6 +88,12 @@ typedef struct { uint32_t body_size; uint32_t sent_bytes; uint32_t audio_frame_count; + unsigned compression; ///< delta compression method used + unsigned bpp; ///< bits per plane to decode (differs from bits_per_coded_sample if HAM) + unsigned ham; ///< 0 if non-HAM or number of hold bits (6 for bpp > 6, 4 otherwise) + unsigned flags; ///< 1 for EHB, 0 is no extra half darkening + unsigned transparency; ///< transparency color index in palette + unsigned masking; ///< masking method used } IffDemuxContext; @@ -126,8 +144,12 @@ static int iff_read_header(AVFormatContext *s, IffDemuxContext *iff = s->priv_data; AVIOContext *pb = s->pb; AVStream *st; + uint8_t *buf; uint32_t chunk_id, data_size; int compression = -1; + uint32_t screenmode = 0; + unsigned transparency = 0; + unsigned masking = 0; // no mask st = av_new_stream(s, 0); if (!st) @@ -171,12 +193,18 @@ static int iff_read_header(AVFormatContext *s, st->codec->channels = (avio_rb32(pb) < 6) ? 1 : 2; break; + case ID_CAMG: + if (data_size < 4) + return AVERROR_INVALIDDATA; + screenmode = avio_rb32(pb); + break; + case ID_CMAP: - st->codec->extradata_size = data_size; - st->codec->extradata = av_malloc(data_size); + 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) return AVERROR(ENOMEM); - if (avio_read(pb, st->codec->extradata, data_size) < 0) + if (avio_read(pb, st->codec->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0) return AVERROR(EIO); break; @@ -188,12 +216,15 @@ static int iff_read_header(AVFormatContext *s, st->codec->height = avio_rb16(pb); avio_skip(pb, 4); // x, y offset st->codec->bits_per_coded_sample = avio_r8(pb); - if (data_size >= 11) { - avio_skip(pb, 1); // masking + if (data_size >= 10) + masking = avio_r8(pb); + if (data_size >= 11) compression = avio_r8(pb); + if (data_size >= 14) { + avio_skip(pb, 1); // padding + transparency = avio_rb16(pb); } if (data_size >= 16) { - avio_skip(pb, 3); // paddding, transparent st->sample_aspect_ratio.num = avio_r8(pb); st->sample_aspect_ratio.den = avio_r8(pb); } @@ -253,6 +284,31 @@ static int iff_read_header(AVFormatContext *s, break; case AVMEDIA_TYPE_VIDEO: + iff->compression = compression; + iff->bpp = st->codec->bits_per_coded_sample; + if ((screenmode & 0x800 /* Hold And Modify */) && iff->bpp <= 8) { + iff->ham = iff->bpp > 6 ? 6 : 4; + st->codec->bits_per_coded_sample = 24; + } + iff->flags = (screenmode & 0x80 /* Extra HalfBrite */) && iff->bpp <= 8; + iff->masking = masking; + iff->transparency = transparency; + + if (!st->codec->extradata) { + st->codec->extradata_size = IFF_EXTRA_VIDEO_SIZE; + st->codec->extradata = av_malloc(IFF_EXTRA_VIDEO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) + return AVERROR(ENOMEM); + } + buf = st->codec->extradata; + bytestream_put_be16(&buf, IFF_EXTRA_VIDEO_SIZE); + bytestream_put_byte(&buf, iff->compression); + bytestream_put_byte(&buf, iff->bpp); + bytestream_put_byte(&buf, iff->ham); + bytestream_put_byte(&buf, iff->flags); + bytestream_put_be16(&buf, iff->transparency); + bytestream_put_byte(&buf, iff->masking); + switch (compression) { case BITMAP_RAW: st->codec->codec_id = CODEC_ID_IFF_ILBM; @@ -293,7 +349,15 @@ static int iff_read_packet(AVFormatContext *s, } interleave_stereo(sample_buffer, pkt->data, PACKET_SIZE); } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { - ret = av_get_packet(pb, pkt, iff->body_size); + uint8_t *buf; + + if (av_new_packet(pkt, iff->body_size + 2) < 0) { + return AVERROR(ENOMEM); + } + + buf = pkt->data; + bytestream_put_be16(&buf, 2); + ret = avio_read(pb, buf, iff->body_size); } else { ret = av_get_packet(pb, pkt, PACKET_SIZE); } From 13e69cc5fa60a7e2bccedc4f59a16c1abcec6b8b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Apr 2011 13:23:51 +0200 Subject: [PATCH 150/172] Fix building on FreeBSD8.2 Signed-off-by: Michael Niedermayer --- configure | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 20ad702ab1..01f9238986 100755 --- a/configure +++ b/configure @@ -2963,7 +2963,14 @@ check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_def check_header dev/ic/bt8xx.h check_header sndio.h -check_header sys/soundcard.h +if check_struct sys/soundcard.h audio_buf_info bytes; then + enable_safe sys/soundcard.h +else + check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE < + audio_buf_info abc; +EOF +fi check_header soundcard.h enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound From 47ec6546d240e3d9a8f76f25e127dcb4a3a9f7b9 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Apr 2011 13:27:07 +0200 Subject: [PATCH 151/172] Drop section describung now unneeded workarounds for BSD Signed-off-by: Michael Niedermayer --- doc/general.texi | 8 -------- 1 file changed, 8 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index 05ce0a0550..3520a3b766 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -789,14 +789,6 @@ to configure. BSD make will not build FFmpeg, you need to install and use GNU Make (@file{gmake}). -@subsubsection FreeBSD, DragonFly BSD - -These systems will not compile out-of-the-box due to broken system headers. -Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work -around the problem. This may have unexpected sideeffects, so use it at -your own risk. If you care about FreeBSD, please make an attempt at -getting the system headers fixed. - @subsection (Open)Solaris GNU Make is required to build FFmpeg, so you have to invoke (@file{gmake}), From e9251bb5555f6daa6be10437f97579d85d6fdc89 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 24 Apr 2011 11:39:15 +0200 Subject: [PATCH 152/172] configure: Add missing libavutil inter-library dependencies to .pc files. This unbreaks static compilation when using pkg-config. Based on an mplayer2 patch by Uoti Urpala Signed-off-by: Diego Biurrun --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index c01c551cf5..6dd00dc161 100755 --- a/configure +++ b/configure @@ -3428,9 +3428,9 @@ EOF } pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" -pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" +pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION" pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION" pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" -pkgconfig_generate libpostproc "Libav post processing library" "$LIBPOSTPROC_VERSION" +pkgconfig_generate libpostproc "Libav post processing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" From dc713546d4ffcd2fbc8e0ecd28fbcf6cd252061a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 24 Apr 2011 15:40:57 +0200 Subject: [PATCH 153/172] oggdec: reindent after 8f3eebd6 Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index d2725792e9..8d96320b3f 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -242,14 +242,14 @@ ogg_read_page (AVFormatContext * s, int *str) idx = ogg_find_stream (ogg, serial); if (idx < 0){ if (ogg->headers) { - int n; + int n; - for (n = 0; n < ogg->nstreams; n++) { - av_freep(&ogg->streams[n].buf); - av_freep(&ogg->streams[n].private); - } - ogg->curidx = -1; - ogg->nstreams = 0; + for (n = 0; n < ogg->nstreams; n++) { + av_freep(&ogg->streams[n].buf); + av_freep(&ogg->streams[n].private); + } + ogg->curidx = -1; + ogg->nstreams = 0; } idx = ogg_new_stream (s, serial); if (idx < 0) From 50f7c296469e9675e07fd1afa37b5e430b876f1c Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 24 Apr 2011 17:24:24 +0200 Subject: [PATCH 154/172] configure: Add missing libm library dependencies to .pc files. This unbreaks static compilation using pkg-config on systems in need of -lm. Based on an mplayer2 patch by Uoti Urpala Signed-off-by: Diego Biurrun --- configure | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 6dd00dc161..f514503785 100755 --- a/configure +++ b/configure @@ -2840,7 +2840,7 @@ for thread in $THREADS_LIST; do fi done -check_lib math.h sin -lm +check_lib math.h sin -lm && LIBM="-lm" enabled vaapi && require vaapi va/va.h vaInitialize -lva check_mathfunc exp2 @@ -3427,10 +3427,10 @@ Cflags: -I\${includedir} EOF } -pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" -pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION" +pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" "$LIBM" +pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs $LIBM" "libavutil = $LIBAVUTIL_VERSION" pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION" pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION" pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" pkgconfig_generate libpostproc "Libav post processing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" -pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION" +pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION" From e3323a1cbdadef21a6cbc98bc6c3e24457b45eab Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Apr 2011 17:46:50 +0200 Subject: [PATCH 155/172] Fix some passing argument from incompatible pointer type warnings. Signed-off-by: Michael Niedermayer --- libavformat/avio.c | 2 +- libavformat/aviobuf.c | 2 +- libavformat/mpegenc.c | 2 +- libavformat/swfenc.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 936a3d979c..2d587b349a 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -307,7 +307,7 @@ int ffurl_write(URLContext *h, const unsigned char *buf, int size) if (h->max_packet_size && size > h->max_packet_size) return AVERROR(EIO); - return retry_transfer_wrapper(h, buf, size, size, h->prot->url_write); + return retry_transfer_wrapper(h, buf, size, size, (void*)h->prot->url_write); } int64_t ffurl_seek(URLContext *h, int64_t pos, int whence) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 71406e0523..9c17e8c6e6 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -853,7 +853,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) if (ffio_init_context(*s, buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h, - ffurl_read, ffurl_write, ffurl_seek) < 0) { + (void*)ffurl_read, (void*)ffurl_write, (void*)ffurl_seek) < 0) { av_free(buffer); av_freep(s); return AVERROR(EIO); diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 0c86df1eea..e42fac4ceb 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -923,7 +923,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index, /* output data */ assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo)); - av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &avio_write); + av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, (void*)avio_write); stream->bytes_to_iframe -= payload_size - stuffing_size; }else{ payload_size= diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c index f5328d0d9d..09c2d61f28 100644 --- a/libavformat/swfenc.c +++ b/libavformat/swfenc.c @@ -421,7 +421,7 @@ static int swf_write_video(AVFormatContext *s, put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG); avio_wl16(pb, swf->sound_samples); avio_wl16(pb, 0); // seek samples - av_fifo_generic_read(swf->audio_fifo, pb, frame_size, &avio_write); + av_fifo_generic_read(swf->audio_fifo, pb, frame_size, (void*)avio_write); put_swf_end_tag(s); /* update FIFO */ From 88dbbe97d598390d96eeb3118437a225296a18ae Mon Sep 17 00:00:00 2001 From: Nicolas George Date: Sat, 23 Apr 2011 11:42:26 +0200 Subject: [PATCH 156/172] general.texi: document libcelt decoder. --- doc/general.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/general.texi b/doc/general.texi index 3520a3b766..82519642d6 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -598,6 +598,8 @@ following image formats are supported: @item Atrac 3 @tab @tab X @item Bink Audio @tab @tab X @tab Used in Bink and Smacker files in many games. +@item CELT (Opus) @tab @tab E + @tab decoding supported through external library libcelt @item Delphine Software International CIN audio @tab @tab X @tab Codec used in Delphine Software International games. @item COOK @tab @tab X From 80da2dcf05efdaa5e8f82b635da245054256a35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 24 Apr 2011 14:39:07 +0200 Subject: [PATCH 157/172] Use av_fast_malloc instead of av_realloc in fraps decoder. --- libavcodec/fraps.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index dd086d2e3f..1bd6fc3a21 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -46,6 +46,7 @@ typedef struct FrapsContext{ AVCodecContext *avctx; AVFrame frame; uint8_t *tmpbuf; + int tmpbuf_size; DSPContext dsp; } FrapsContext; @@ -272,7 +273,7 @@ static int decode_frame(AVCodecContext *avctx, offs[planes] = buf_size; for(i = 0; i < planes; i++){ is_chroma = !!i; - s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&s->tmpbuf, &s->tmpbuf_size, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); if(fraps2_decode_plane(s, f->data[i], f->linesize[i], avctx->width >> is_chroma, avctx->height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); @@ -314,7 +315,7 @@ static int decode_frame(AVCodecContext *avctx, } offs[planes] = buf_size; for(i = 0; i < planes; i++){ - s->tmpbuf = av_realloc(s->tmpbuf, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&s->tmpbuf, &s->tmpbuf_size, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0], avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); From 67c1a59ad7f9057f86d1605df3c28db0edb99bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 24 Apr 2011 14:49:29 +0200 Subject: [PATCH 158/172] Check for malloc failures in fraps decoder. --- libavcodec/fraps.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 1bd6fc3a21..8d40ed2fa7 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -274,6 +274,8 @@ static int decode_frame(AVCodecContext *avctx, for(i = 0; i < planes; i++){ is_chroma = !!i; av_fast_malloc(&s->tmpbuf, &s->tmpbuf_size, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->tmpbuf) + return AVERROR(ENOMEM); if(fraps2_decode_plane(s, f->data[i], f->linesize[i], avctx->width >> is_chroma, avctx->height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); @@ -316,6 +318,8 @@ static int decode_frame(AVCodecContext *avctx, offs[planes] = buf_size; for(i = 0; i < planes; i++){ av_fast_malloc(&s->tmpbuf, &s->tmpbuf_size, offs[i + 1] - offs[i] - 1024 + FF_INPUT_BUFFER_PADDING_SIZE); + if (!s->tmpbuf) + return AVERROR(ENOMEM); if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0], avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); From e4253b1a4f5e296dfb41620c02e08650609e6819 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Wed, 20 Apr 2011 21:41:43 -0700 Subject: [PATCH 159/172] CrystalHD: Add AVOption to configure hardware downscaling. The CrystalHD hardware can do scaling, which is particularly desirable when dealing with some high resolution clips that take so long to decode and copy out that they end up playing back slower than realtime. By using scaling, we can make the output frames smaller and reduce the copy out time. This option takes the desired horizontal width in pixels, and the hardware will do an aspect-scale. Upscaling is not supported and the hardware will simply ignore any request to do so. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 9bbb6e8bba..1a2d60c672 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -87,6 +87,7 @@ #include "h264.h" #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" /** Timeout parameter passed to DtsProcOutput() in us */ #define OUTPUT_PROC_TIMEOUT 50 @@ -118,6 +119,7 @@ typedef struct OpaqueList { } OpaqueList; typedef struct { + AVClass *av_class; AVCodecContext *avctx; AVFrame pic; HANDLE dev; @@ -137,8 +139,20 @@ typedef struct { OpaqueList *head; OpaqueList *tail; + + /* Options */ + uint32_t sWidth; } CHDContext; +static const AVOption options[] = { + { "crystalhd_downscale_width", + "Turn on downscaling to the specified width", + offsetof(CHDContext, sWidth), + FF_OPT_TYPE_INT, 0, 0, UINT32_MAX, + AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, }, + { NULL, }, +}; + /***************************************************************************** * Helper functions @@ -434,6 +448,11 @@ static av_cold int init(AVCodecContext *avctx) } format.mSubtype = subtype; + if (priv->sWidth) { + format.bEnableScaling = 1; + format.ScalingParams.sWidth = priv->sWidth; + } + /* Get a decoder instance */ av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: starting up\n"); // Initialize the Link and Decoder devices @@ -948,6 +967,13 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *a #if CONFIG_H264_CRYSTALHD_DECODER +static AVClass h264_class = { + "h264_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_h264_crystalhd_decoder = { .name = "h264_crystalhd", .type = AVMEDIA_TYPE_VIDEO, @@ -960,10 +986,18 @@ AVCodec ff_h264_crystalhd_decoder = { .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (CrystalHD acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &h264_class, }; #endif #if CONFIG_MPEG2_CRYSTALHD_DECODER +static AVClass mpeg2_class = { + "mpeg2_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_mpeg2_crystalhd_decoder = { .name = "mpeg2_crystalhd", .type = AVMEDIA_TYPE_VIDEO, @@ -976,10 +1010,18 @@ AVCodec ff_mpeg2_crystalhd_decoder = { .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Video (CrystalHD acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &mpeg2_class, }; #endif #if CONFIG_MPEG4_CRYSTALHD_DECODER +static AVClass mpeg4_class = { + "mpeg4_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_mpeg4_crystalhd_decoder = { .name = "mpeg4_crystalhd", .type = AVMEDIA_TYPE_VIDEO, @@ -992,10 +1034,18 @@ AVCodec ff_mpeg4_crystalhd_decoder = { .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Part 2 (CrystalHD acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &mpeg4_class, }; #endif #if CONFIG_MSMPEG4_CRYSTALHD_DECODER +static AVClass msmpeg4_class = { + "msmpeg4_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_msmpeg4_crystalhd_decoder = { .name = "msmpeg4_crystalhd", .type = AVMEDIA_TYPE_VIDEO, @@ -1008,10 +1058,18 @@ AVCodec ff_msmpeg4_crystalhd_decoder = { .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Part 2 Microsoft variant version 3 (CrystalHD acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &msmpeg4_class, }; #endif #if CONFIG_VC1_CRYSTALHD_DECODER +static AVClass vc1_class = { + "vc1_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_vc1_crystalhd_decoder = { .name = "vc1_crystalhd", .type = AVMEDIA_TYPE_VIDEO, @@ -1024,10 +1082,18 @@ AVCodec ff_vc1_crystalhd_decoder = { .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 (CrystalHD acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &vc1_class, }; #endif #if CONFIG_WMV3_CRYSTALHD_DECODER +static AVClass wmv3_class = { + "wmv3_crystalhd", + av_default_item_name, + options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_wmv3_crystalhd_decoder = { .name = "wmv3_crystalhd", .type = AVMEDIA_TYPE_VIDEO, @@ -1040,5 +1106,6 @@ AVCodec ff_wmv3_crystalhd_decoder = { .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 (CrystalHD acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUYV422, PIX_FMT_NONE}, + .priv_class = &wmv3_class, }; #endif From ac9cf2e5c48aa1edb2c7ba8e7edfa55c9fde609b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 24 Apr 2011 20:10:37 +0300 Subject: [PATCH 160/172] crypto: Use av_freep instead of av_free MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using av_freep is generally good practice. Signed-off-by: Martin Storsjö --- libavformat/crypto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/crypto.c b/libavformat/crypto.c index ea6012ad09..fecc2c961c 100644 --- a/libavformat/crypto.c +++ b/libavformat/crypto.c @@ -153,9 +153,9 @@ static int crypto_close(URLContext *h) CryptoContext *c = h->priv_data; if (c->hd) ffurl_close(c->hd); - av_free(c->aes); - av_free(c->key); - av_free(c->iv); + av_freep(&c->aes); + av_freep(&c->key); + av_freep(&c->iv); return 0; } From 5f85d49b6889b9a2ecd18695fe52c5c9b698a0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 24 Apr 2011 20:19:49 +0300 Subject: [PATCH 161/172] applehttp: Don't export variant_bitrate if it isn't known MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there are no variants, the total bitrate of the single stream isn't known, and exporting variant_bitrate = 0 does look weird, since there really aren't any variants. Signed-off-by: Martin Storsjö --- libavformat/applehttp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 2e0e8a1b3a..822d80bb00 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -505,7 +505,9 @@ static int applehttp_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; } avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); - av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str, 0); + if (v->bandwidth) + av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str, + 0); } stream_offset += v->ctx->nb_streams; } From 8a68697dc66234d0a5fc50b4d67a94921c9893d1 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Apr 2011 21:29:35 +0200 Subject: [PATCH 162/172] Add flag to force demuxers to sort more strictly by dts. This enables non interleaved AVI mode for example. Players that are picky on strict interleaving can set this. Patches to only switch to non intereaved AVI mode when the index is not strictly correctly interleaved are welcome. Signed-off-by: Michael Niedermayer --- libavformat/avformat.h | 1 + libavformat/avidec.c | 2 +- libavformat/options.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 767356a439..2f41f7263b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -726,6 +726,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container #define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled #define AVFMT_FLAG_RTP_HINT 0x0040 ///< Add RTP hinting to the output file +#define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) int loop_input; diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 9d657e0db6..77d068658f 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -726,7 +726,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) if(!avi->index_loaded && pb->seekable) avi_load_index(s); avi->index_loaded = 1; - avi->non_interleaved |= guess_ni_flag(s); + avi->non_interleaved |= guess_ni_flag(s) | (s->flags & AVFMT_FLAG_SORT_DTS); for(i=0; inb_streams; i++){ AVStream *st = s->streams[i]; if(st->nb_index_entries) diff --git a/libavformat/options.c b/libavformat/options.c index 214c62f9a7..0a87f2b12c 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -50,6 +50,7 @@ static const AVOption options[]={ {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOPARSE, INT_MIN, INT_MAX, D, "fflags"}, {"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"}, {"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_RTP_HINT, INT_MIN, INT_MAX, E, "fflags"}, +{"sortdts", "try to interleave outputted packets by dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_SORT_DTS, INT_MIN, INT_MAX, D, "fflags"}, {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 5*AV_TIME_BASE, 0, INT_MAX, D}, {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D}, {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D}, From fbfcc8f1b71b51ff87f09e269d22328be5594f40 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 24 Apr 2011 22:38:05 +0200 Subject: [PATCH 163/172] avi: try to synchronize the points in time of the starts of streams after seeking. Signed-off-by: Michael Niedermayer --- libavformat/avidec.c | 25 +++++++++++++------------ tests/ref/seek/lavf_avi | 16 ++++++++-------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 77d068658f..83c55d08e9 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -54,6 +54,8 @@ typedef struct AVIStream { AVFormatContext *sub_ctx; AVPacket sub_pkt; uint8_t *sub_buffer; + + int64_t seek_pos; } AVIStream; typedef struct { @@ -987,6 +989,12 @@ resync: ast->packet_size= 0; } + if(!avi->non_interleaved && ast->seek_pos > pkt->pos){ + av_free_packet(pkt); + goto resync; + } + ast->seek_pos= 0; + return size; } @@ -1252,7 +1260,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp AVIContext *avi = s->priv_data; AVStream *st; int i, index; - int64_t pos; + int64_t pos, pos_min; AVIStream *ast; if (!avi->index_loaded) { @@ -1289,6 +1297,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp return 0; } + pos_min= pos; for(i = 0; i < s->nb_streams; i++) { AVStream *st2 = s->streams[i]; AVIStream *ast2 = st2->priv_data; @@ -1312,21 +1321,13 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp flags | AVSEEK_FLAG_BACKWARD); if(index<0) index=0; - - if(!avi->non_interleaved){ - while(index>0 && st2->index_entries[index].pos > pos) - index--; - while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos) - index++; - } - -// av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp); - /* extract the current frame number */ + ast2->seek_pos= st2->index_entries[index].pos; + pos_min= FFMIN(pos_min,ast2->seek_pos); ast2->frame_offset = st2->index_entries[index].timestamp; } /* do the seek */ - avio_seek(s->pb, pos, SEEK_SET); + avio_seek(s->pb, pos_min, SEEK_SET); avi->stream_index= -1; return 0; } diff --git a/tests/ref/seek/lavf_avi b/tests/ref/seek/lavf_avi index 964f0b8b6f..6253960efd 100644 --- a/tests/ref/seek/lavf_avi +++ b/tests/ref/seek/lavf_avi @@ -8,27 +8,27 @@ ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864 ret:-1 st: 0 flags:1 ts:-0.320000 ret:-1 st: 1 flags:0 ts: 2.586122 ret: 0 st: 1 flags:1 ts: 1.462857 -ret: 0 st: 1 flags:1 dts: 1.018776 pts: 1.018776 pos: 329774 size: 209 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 156166 size: 27955 +ret: 0 st: 1 flags:1 dts: 0.470204 pts: 0.470204 pos: 155948 size: 209 ret:-1 st:-1 flags:1 ts:-0.740831 ret:-1 st: 0 flags:0 ts: 2.160000 ret: 0 st: 0 flags:1 ts: 1.040000 ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864 ret: 0 st: 1 flags:0 ts:-0.052245 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 37784 size: 208 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867 ret: 0 st: 1 flags:1 ts: 2.847347 -ret: 0 st: 1 flags:1 dts: 1.018776 pts: 1.018776 pos: 329774 size: 209 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864 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: 156166 size: 27955 +ret: 0 st: 1 flags:1 dts: 0.470204 pts: 0.470204 pos: 155948 size: 209 ret: 0 st: 0 flags:0 ts:-0.480000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867 ret: 0 st: 0 flags:1 ts: 2.400000 ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864 ret:-1 st: 1 flags:0 ts: 1.306122 ret: 0 st: 1 flags:1 ts: 0.208980 -ret: 0 st: 1 flags:1 dts: 0.208980 pts: 0.208980 pos: 92800 size: 209 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867 ret: 0 st:-1 flags:0 ts:-0.904994 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867 ret: 0 st:-1 flags:1 ts: 1.989173 @@ -38,7 +38,7 @@ ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864 ret:-1 st: 0 flags:1 ts:-0.240000 ret:-1 st: 1 flags:0 ts: 2.664490 ret: 0 st: 1 flags:1 ts: 1.567347 -ret: 0 st: 1 flags:1 dts: 1.018776 pts: 1.018776 pos: 329774 size: 209 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 156166 size: 27955 +ret: 0 st: 1 flags:1 dts: 0.470204 pts: 0.470204 pos: 155948 size: 209 ret:-1 st:-1 flags:1 ts:-0.645825 From 69f58958ce8f81b153b14c60959ba37d6bf0b8cf Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 22 Apr 2011 17:11:23 +0200 Subject: [PATCH 164/172] ffplay: avoid SIGFPE exception in SDL_DisplayYUVOverlay In video_image_display(), fix exception occurring when the size of the rectangle passed to SDL_DisplayYUVOverlay() is 0x0, which happens when interactively resizing the SDL window. This is done by forcing the minimum size to 1x1. Signed-off-by: Stefano Sabatini --- ffplay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffplay.c b/ffplay.c index 680215a481..b342732d7e 100644 --- a/ffplay.c +++ b/ffplay.c @@ -752,8 +752,8 @@ static void video_image_display(VideoState *is) } rect.x = is->xleft + x; rect.y = is->ytop + y; - rect.w = width; - rect.h = height; + rect.w = FFMAX(width, 1); + rect.h = FFMAX(height, 1); SDL_DisplayYUVOverlay(vp->bmp, &rect); } else { #if 0 From 02e3f7d042aabd98d4114f7f84b4b480a93daaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 24 Apr 2011 19:17:17 +0200 Subject: [PATCH 165/172] Support PARSER_FLAG_COMPLETE_FRAMES for h261 and h263 parsers. --- libavcodec/h261_parser.c | 4 ++++ libavcodec/h263_parser.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libavcodec/h261_parser.c b/libavcodec/h261_parser.c index defc1cb46f..4d20afe8d6 100644 --- a/libavcodec/h261_parser.c +++ b/libavcodec/h261_parser.c @@ -70,12 +70,16 @@ static int h261_parse(AVCodecParserContext *s, ParseContext *pc = s->priv_data; int next; + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { next= h261_find_frame_end(pc,avctx, buf, buf_size); if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { *poutbuf = NULL; *poutbuf_size = 0; return buf_size; } + } *poutbuf = buf; *poutbuf_size = buf_size; return next; diff --git a/libavcodec/h263_parser.c b/libavcodec/h263_parser.c index e08198324b..2a00291ec2 100644 --- a/libavcodec/h263_parser.c +++ b/libavcodec/h263_parser.c @@ -70,6 +70,9 @@ static int h263_parse(AVCodecParserContext *s, ParseContext *pc = s->priv_data; int next; + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { next= ff_h263_find_frame_end(pc, buf, buf_size); if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { @@ -77,6 +80,7 @@ static int h263_parse(AVCodecParserContext *s, *poutbuf_size = 0; return buf_size; } + } *poutbuf = buf; *poutbuf_size = buf_size; From 9a962f30556f8890a09cd668a9fe806ebac54206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Mon, 25 Apr 2011 00:02:36 +0200 Subject: [PATCH 166/172] Fix indentation. --- libavcodec/h261_parser.c | 12 ++++++------ libavcodec/h263_parser.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/h261_parser.c b/libavcodec/h261_parser.c index 4d20afe8d6..3fb86db125 100644 --- a/libavcodec/h261_parser.c +++ b/libavcodec/h261_parser.c @@ -73,12 +73,12 @@ static int h261_parse(AVCodecParserContext *s, if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { next = buf_size; } else { - next= h261_find_frame_end(pc,avctx, buf, buf_size); - if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; - } + next= h261_find_frame_end(pc,avctx, buf, buf_size); + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } } *poutbuf = buf; *poutbuf_size = buf_size; diff --git a/libavcodec/h263_parser.c b/libavcodec/h263_parser.c index 2a00291ec2..a3d24ea433 100644 --- a/libavcodec/h263_parser.c +++ b/libavcodec/h263_parser.c @@ -73,13 +73,13 @@ static int h263_parse(AVCodecParserContext *s, if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { next = buf_size; } else { - next= ff_h263_find_frame_end(pc, buf, buf_size); + next= ff_h263_find_frame_end(pc, buf, buf_size); - if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; - } + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } } *poutbuf = buf; From 3e1c59ebc642831395bb5bcdc763520722679a6c Mon Sep 17 00:00:00 2001 From: ami_stuff Date: Mon, 25 Apr 2011 00:20:27 +0200 Subject: [PATCH 167/172] Support fourcc auv2. Fixes ticket #101. --- libavcodec/raw.c | 1 + libavformat/riff.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 26b4df6d57..e607148a2b 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c @@ -61,6 +61,7 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_UYVY422, MKTAG('A', 'V', '1', 'x') }, /* Avid 1:1x */ { PIX_FMT_UYVY422, MKTAG('A', 'V', 'u', 'p') }, { PIX_FMT_UYVY422, MKTAG('V', 'D', 'T', 'Z') }, /* SoftLab-NSK VideoTizer */ + { PIX_FMT_UYVY422, MKTAG('a', 'u', 'v', '2') }, { PIX_FMT_UYYVYY411, MKTAG('Y', '4', '1', '1') }, { PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') }, { PIX_FMT_NV12, MKTAG('N', 'V', '1', '2') }, diff --git a/libavformat/riff.c b/libavformat/riff.c index e884780b76..6b093b2683 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -181,6 +181,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', 'B') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'V', '9') }, { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, + { CODEC_ID_RAWVIDEO, MKTAG('a', 'u', 'v', '2') }, { CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') }, { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') }, { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, From a8117a62f41c53eafde94bd84415a3f552824dcd Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 25 Apr 2011 00:27:03 +0200 Subject: [PATCH 168/172] Support fourcc M263. Fixes ticket #103. --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 6b093b2683..80a1b719ec 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -40,6 +40,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_H263, MKTAG('L', '2', '6', '3') }, { CODEC_ID_H263, MKTAG('V', 'X', '1', 'K') }, { CODEC_ID_H263, MKTAG('Z', 'y', 'G', 'o') }, + { CODEC_ID_H263, MKTAG('M', '2', '6', '3') }, { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') }, { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */ { CODEC_ID_H261, MKTAG('H', '2', '6', '1') }, From 69cf1824c6001ccc37d9ece5308c9a8f8d1dec26 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 25 Apr 2011 00:35:59 +0200 Subject: [PATCH 169/172] Support fourcc XVIX. Fixes ticket #106. --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 80a1b719ec..3950a06c26 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -84,6 +84,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MPEG4, MKTAG('U', 'L', 'D', 'X') }, { CODEC_ID_MPEG4, MKTAG('G', 'E', 'O', 'V') }, { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */ + { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'X') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, From 03546a9ac8753b3f083ae3d2a6397c8c0011923b Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Mon, 25 Apr 2011 00:43:13 +0200 Subject: [PATCH 170/172] Support fourcc MMJP. Fixes ticket #107. --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 3950a06c26..48a8df4e18 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -151,6 +151,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { CODEC_ID_MJPEG, MKTAG('A', 'V', 'I', '2') }, { CODEC_ID_MJPEG, MKTAG('M', 'T', 'S', 'J') }, { CODEC_ID_MJPEG, MKTAG('Z', 'J', 'P', 'G') }, /* Paradigm Matrix M-JPEG Codec */ + { CODEC_ID_MJPEG, MKTAG('M', 'M', 'J', 'P') }, { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') }, { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') }, { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') }, From 2441003d3fdc01545690c2f397efd7acfd876d6c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 24 Apr 2011 19:49:39 +0200 Subject: [PATCH 171/172] vorbisdec: Employ proper printf format specifiers for uint_fast32_t. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libavcodec/vorbisdec.c:543: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘uint_fast32_t’ libavcodec/vorbisdec.c:543: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘uint_fast32_t’ --- libavcodec/vorbisdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 5fa7be1365..d42507df84 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -539,7 +539,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) rangemax = (1 << rangebits); if (rangemax > vc->blocksize[1] / 2) { av_log(vc->avccontext, AV_LOG_ERROR, - "Floor value is too large for blocksize: %d (%d)\n", + "Floor value is too large for blocksize: %"PRIuFAST32" (%"PRIuFAST32")\n", rangemax, vc->blocksize[1] / 2); return -1; } From 2671ab3996672c43b02076daca5bf00c5a6f1c68 Mon Sep 17 00:00:00 2001 From: unknown author Date: Mon, 25 Apr 2011 01:48:46 +0200 Subject: [PATCH 172/172] Check mmap() return against correct value Signed-off-by: Michael Niedermayer --- libswscale/utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libswscale/utils.c b/libswscale/utils.c index a343bf2570..6e8e40b5cc 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -919,7 +919,11 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize); #endif +#ifdef MAP_ANONYMOUS + if (c->lumMmx2FilterCode == MAP_FAILED || c->chrMmx2FilterCode == MAP_FAILED) +#else if (!c->lumMmx2FilterCode || !c->chrMmx2FilterCode) +#endif return AVERROR(ENOMEM); FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int16_t), fail); FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int16_t), fail);