From 7b2121e7e2e161f0610fa89d168f3b85d2ca58fb Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 17 Oct 2012 21:32:13 +0200 Subject: [PATCH 1/7] riff: Move functions around to be covered by appropriate #ifdefs This fixes compilation with --disable-muxers. --- libavformat/riff.c | 158 ++++++++++++++++++++++----------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/libavformat/riff.c b/libavformat/riff.c index d591aa81e0..3676b76f54 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -531,6 +531,84 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *t if (!for_asf && enc->extradata_size & 1) avio_w8(pb, 0); } + +void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale) +{ + int gcd; + int audio_frame_size; + + /* We use the known constant frame size for the codec if known, otherwise + fallback to using AVCodecContext.frame_size, which is not as reliable + for indicating packet duration */ + audio_frame_size = av_get_audio_frame_duration(stream, 0); + if (!audio_frame_size) + audio_frame_size = stream->frame_size; + + *au_ssize= stream->block_align; + if (audio_frame_size && stream->sample_rate) { + *au_scale = audio_frame_size; + *au_rate= stream->sample_rate; + }else if(stream->codec_type == AVMEDIA_TYPE_VIDEO || + stream->codec_type == AVMEDIA_TYPE_DATA || + stream->codec_type == AVMEDIA_TYPE_SUBTITLE){ + *au_scale= stream->time_base.num; + *au_rate = stream->time_base.den; + }else{ + *au_scale= stream->block_align ? stream->block_align*8 : 8; + *au_rate = stream->bit_rate ? stream->bit_rate : 8*stream->sample_rate; + } + gcd= av_gcd(*au_scale, *au_rate); + *au_scale /= gcd; + *au_rate /= gcd; +} + +void ff_riff_write_info_tag(AVIOContext *pb, const char *tag, const char *str) +{ + int len = strlen(str); + if (len > 0) { + len++; + ffio_wfourcc(pb, tag); + avio_wl32(pb, len); + avio_put_str(pb, str); + if (len & 1) + avio_w8(pb, 0); + } +} + +static int riff_has_valid_tags(AVFormatContext *s) +{ + int i; + AVDictionaryEntry *t = NULL; + + for (i = 0; *ff_riff_tags[i]; i++) { + if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) + return 1; + } + + return 0; +} + +void ff_riff_write_info(AVFormatContext *s) +{ + AVIOContext *pb = s->pb; + int i; + int64_t list_pos; + AVDictionaryEntry *t = NULL; + + ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL); + + /* writing empty LIST is not nice and may cause problems */ + if (!riff_has_valid_tags(s)) + return; + + list_pos = ff_start_tag(pb, "LIST"); + ffio_wfourcc(pb, "INFO"); + for (i = 0; *ff_riff_tags[i]; i++) { + if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) + ff_riff_write_info_tag(s->pb, t->key, t->value); + } + ff_end_tag(pb, list_pos); +} #endif //CONFIG_MUXERS #if CONFIG_DEMUXERS @@ -632,37 +710,6 @@ int ff_get_bmp_header(AVIOContext *pb, AVStream *st) avio_rl32(pb); /* ClrImportant */ return tag1; } -#endif // CONFIG_DEMUXERS - -void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale) -{ - int gcd; - int audio_frame_size; - - /* We use the known constant frame size for the codec if known, otherwise - fallback to using AVCodecContext.frame_size, which is not as reliable - for indicating packet duration */ - audio_frame_size = av_get_audio_frame_duration(stream, 0); - if (!audio_frame_size) - audio_frame_size = stream->frame_size; - - *au_ssize= stream->block_align; - if (audio_frame_size && stream->sample_rate) { - *au_scale = audio_frame_size; - *au_rate= stream->sample_rate; - }else if(stream->codec_type == AVMEDIA_TYPE_VIDEO || - stream->codec_type == AVMEDIA_TYPE_DATA || - stream->codec_type == AVMEDIA_TYPE_SUBTITLE){ - *au_scale= stream->time_base.num; - *au_rate = stream->time_base.den; - }else{ - *au_scale= stream->block_align ? stream->block_align*8 : 8; - *au_rate = stream->bit_rate ? stream->bit_rate : 8*stream->sample_rate; - } - gcd= av_gcd(*au_scale, *au_rate); - *au_scale /= gcd; - *au_rate /= gcd; -} int ff_read_riff_info(AVFormatContext *s, int64_t size) { @@ -708,51 +755,4 @@ int ff_read_riff_info(AVFormatContext *s, int64_t size) return 0; } - -static int riff_has_valid_tags(AVFormatContext *s) -{ - int i; - AVDictionaryEntry *t = NULL; - - for (i = 0; *ff_riff_tags[i]; i++) { - if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) - return 1; - } - - return 0; -} - -void ff_riff_write_info_tag(AVIOContext *pb, const char *tag, const char *str) -{ - int len = strlen(str); - if (len > 0) { - len++; - ffio_wfourcc(pb, tag); - avio_wl32(pb, len); - avio_put_str(pb, str); - if (len & 1) - avio_w8(pb, 0); - } -} - -void ff_riff_write_info(AVFormatContext *s) -{ - AVIOContext *pb = s->pb; - int i; - int64_t list_pos; - AVDictionaryEntry *t = NULL; - - ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL); - - /* writing empty LIST is not nice and may cause problems */ - if (!riff_has_valid_tags(s)) - return; - - list_pos = ff_start_tag(pb, "LIST"); - ffio_wfourcc(pb, "INFO"); - for (i = 0; *ff_riff_tags[i]; i++) { - if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) - ff_riff_write_info_tag(s->pb, t->key, t->value); - } - ff_end_tag(pb, list_pos); -} +#endif // CONFIG_DEMUXERS From e8fe208be8107a55621733b2d0deb2feb762f3d4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 18 Oct 2012 17:48:14 +0200 Subject: [PATCH 2/7] fate: dependencies for screen codec tests --- tests/fate/screen.mak | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/fate/screen.mak b/tests/fate/screen.mak index 8ae7e90ab7..3dc69c5c4e 100644 --- a/tests/fate/screen.mak +++ b/tests/fate/screen.mak @@ -1,8 +1,8 @@ # FIXME dropped frames in this test because of coarse timebase -FATE_SAMPLES_AVCONV += fate-cscd +FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, CSCD) += fate-cscd fate-cscd: CMD = framecrc -i $(SAMPLES)/CSCD/sample_video.avi -an -pix_fmt rgb24 -FATE_SAMPLES_AVCONV += fate-dxtory +FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, DXTORY) += fate-dxtory fate-dxtory: CMD = framecrc -i $(SAMPLES)/dxtory/dxtory_mic.avi FATE_FRAPS += fate-fraps-v0 @@ -23,7 +23,7 @@ fate-fraps-v4: CMD = framecrc -i $(SAMPLES)/fraps/WoW_2006-11-03_14-58-17-19-nos FATE_FRAPS += fate-fraps-v5 fate-fraps-v5: CMD = framecrc -i $(SAMPLES)/fraps/fraps-v5-bouncing-balls-partial.avi -FATE_SAMPLES_AVCONV += $(FATE_FRAPS) +FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, FRAPS) += $(FATE_FRAPS) fate-fraps: $(FATE_FRAPS) FATE_TSCC += fate-tscc-15bit @@ -32,7 +32,7 @@ fate-tscc-15bit: CMD = framecrc -i $(SAMPLES)/tscc/oneminute.avi -t 15 -pix_fmt FATE_TSCC += fate-tscc-32bit fate-tscc-32bit: CMD = framecrc -i $(SAMPLES)/tscc/2004-12-17-uebung9-partial.avi -pix_fmt rgb24 -an -FATE_SAMPLES_AVCONV += $(FATE_TSCC) +FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, TSCC) += $(FATE_TSCC) fate-tscc: $(FATE_TSCC) FATE_VMNC += fate-vmnc-16bit @@ -41,7 +41,7 @@ fate-vmnc-16bit: CMD = framecrc -i $(SAMPLES)/VMnc/test.avi -pix_fmt rgb24 FATE_VMNC += fate-vmnc-32bit fate-vmnc-32bit: CMD = framecrc -i $(SAMPLES)/VMnc/VS2k5DebugDemo-01-partial.avi -pix_fmt rgb24 -FATE_SAMPLES_AVCONV += $(FATE_VMNC) +FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, VMNC) += $(FATE_VMNC) fate-vmnc: $(FATE_VMNC) FATE_ZMBV += fate-zmbv-8bit @@ -56,5 +56,5 @@ fate-zmbv-16bit: CMD = framecrc -i $(SAMPLES)/zmbv/zmbv_16bit.avi -pix_fmt rgb24 FATE_ZMBV += fate-zmbv-32bit fate-zmbv-32bit: CMD = framecrc -i $(SAMPLES)/zmbv/zmbv_32bit.avi -pix_fmt rgb24 -t 25 -FATE_SAMPLES_AVCONV += $(FATE_ZMBV) +FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, ZMBV) += $(FATE_ZMBV) fate-zmbv: $(FATE_ZMBV) From 7a12d97eb1aac6621f20cb7bffd0f74f8e46ae2c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 18 Oct 2012 15:32:11 +0100 Subject: [PATCH 3/7] aac: fix build with hardcoded tables aac_tablegen.h includes aac.h for the POW_SF2_ZERO definition, but this also pulls in a raft of other headers, some of which are not safe to use in code built with the host compiler. Moving POW_SF2_ZERO to aac_tablegen_decl.h, where the declaration of the array it relates to already resides, fixes the problems. Signed-off-by: Mans Rullgard --- libavcodec/aac.h | 1 - libavcodec/aac_tablegen.h | 1 - libavcodec/aac_tablegen_decl.h | 2 ++ 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 32baf9d0c5..9c6ac277d5 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -141,7 +141,6 @@ typedef struct PredictorState { #define SCALE_MAX_POS 255 ///< scalefactor index maximum value #define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard #define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference -#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0); /** * Long Term Prediction diff --git a/libavcodec/aac_tablegen.h b/libavcodec/aac_tablegen.h index 8773d9b975..a45de9a67e 100644 --- a/libavcodec/aac_tablegen.h +++ b/libavcodec/aac_tablegen.h @@ -29,7 +29,6 @@ #include "libavcodec/aac_tables.h" #else #include "libavutil/mathematics.h" -#include "aac.h" float ff_aac_pow2sf_tab[428]; void ff_aac_tableinit(void) diff --git a/libavcodec/aac_tablegen_decl.h b/libavcodec/aac_tablegen_decl.h index 496ca0c677..a5fd1cf345 100644 --- a/libavcodec/aac_tablegen_decl.h +++ b/libavcodec/aac_tablegen_decl.h @@ -23,6 +23,8 @@ #ifndef AVCODEC_AAC_TABLEGEN_DECL_H #define AVCODEC_AAC_TABLEGEN_DECL_H +#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0); + #if CONFIG_HARDCODED_TABLES #define ff_aac_tableinit() extern const float ff_aac_pow2sf_tab[428]; From 0de9380be54e9ccf49631a93f49cff8b8329ec54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 17 Oct 2012 01:45:39 +0300 Subject: [PATCH 4/7] rtp: Update the check for distinguishing between RTP and RTCP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add enums for more RTCP packet types, according to the IANA list of registered types. Signed-off-by: Martin Storsjö --- libavformat/rtp.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libavformat/rtp.h b/libavformat/rtp.h index b01caebb32..6df4ed4f19 100644 --- a/libavformat/rtp.h +++ b/libavformat/rtp.h @@ -84,13 +84,24 @@ enum AVCodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type); /* RTCP packet types */ enum RTCPType { + RTCP_FIR = 192, + RTCP_NACK, // 193 + RTCP_SMPTETC,// 194 + RTCP_IJ, // 195 RTCP_SR = 200, RTCP_RR, // 201 RTCP_SDES, // 202 RTCP_BYE, // 203 - RTCP_APP // 204 + RTCP_APP, // 204 + RTCP_RTPFB,// 205 + RTCP_PSFB, // 206 + RTCP_XR, // 207 + RTCP_AVB, // 208 + RTCP_RSI, // 209 + RTCP_TOKEN,// 210 }; -#define RTP_PT_IS_RTCP(x) ((x) >= RTCP_SR && (x) <= RTCP_APP) +#define RTP_PT_IS_RTCP(x) (((x) >= RTCP_FIR && (x) <= RTCP_IJ) || \ + ((x) >= RTCP_SR && (x) <= RTCP_TOKEN)) #endif /* AVFORMAT_RTP_H */ From 1c37744963acbeb1258ccda9bd772dd51da0479e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 17 Oct 2012 15:24:46 +0300 Subject: [PATCH 5/7] rtsp: Vertically align a constant definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtsp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index d16c98ca8a..55326e9e05 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -390,7 +390,7 @@ typedef struct RTSPState { #define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets - receive packets only from the right source address and port. */ -#define RTSP_FLAG_LISTEN 0x2 /**< Wait for incoming connections. */ +#define RTSP_FLAG_LISTEN 0x2 /**< Wait for incoming connections. */ /** * Describe a single stream, as identified by a single m= line block in the From 3f055f8f5f711cc3c4bf26dfc2d84f98ca46c854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 17 Oct 2012 15:46:30 +0300 Subject: [PATCH 6/7] rtsp: Allow setting the reordering buffer size via an AVOption MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/rtsp.c | 16 ++++++++++++++-- libavformat/rtsp.h | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index df272188a8..160c0f7bbc 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -74,6 +74,9 @@ { "audio", "Audio", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_AUDIO}, 0, 0, DEC, "allowed_media_types" }, \ { "data", "Data", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_DATA}, 0, 0, DEC, "allowed_media_types" } +#define RTSP_REORDERING_OPTS() \ + { "reorder_queue_size", "Number of packets to buffer for handling of reordered packets", OFFSET(reordering_queue_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC } + const AVOption ff_rtsp_options[] = { { "initial_pause", "Don't start playing the stream immediately", OFFSET(initial_pause), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC }, FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags), @@ -87,17 +90,20 @@ const AVOption ff_rtsp_options[] = { { "min_port", "Minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC }, { "max_port", "Maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC }, { "timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies flag listen", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC }, + RTSP_REORDERING_OPTS(), { NULL }, }; static const AVOption sdp_options[] = { RTSP_FLAG_OPTS("sdp_flags", "SDP flags"), RTSP_MEDIATYPE_OPTS("allowed_media_types", "Media types to accept from the server"), + RTSP_REORDERING_OPTS(), { NULL }, }; static const AVOption rtp_options[] = { RTSP_FLAG_OPTS("rtp_flags", "RTP flags"), + RTSP_REORDERING_OPTS(), { NULL }, }; @@ -607,6 +613,13 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) { RTSPState *rt = s->priv_data; AVStream *st = NULL; + int reordering_queue_size = rt->reordering_queue_size; + if (reordering_queue_size < 0) { + if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay) + reordering_queue_size = 0; + else + reordering_queue_size = RTP_REORDER_QUEUE_DEFAULT_SIZE; + } /* open the RTP context */ if (rtsp_st->stream_index >= 0) @@ -631,8 +644,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) else if (CONFIG_RTPDEC) rtsp_st->transport_priv = ff_rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, - (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay) - ? 0 : RTP_REORDER_QUEUE_DEFAULT_SIZE); + reordering_queue_size); if (!rtsp_st->transport_priv) { return AVERROR(ENOMEM); diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 55326e9e05..2812fcb393 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -385,6 +385,11 @@ typedef struct RTSPState { * Timeout to wait for incoming connections. */ int initial_timeout; + + /** + * Size of RTP packet reordering queue. + */ + int reordering_queue_size; } RTSPState; #define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets - From 1cd432e167b1a80853760c89a33606e2b5f229c2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 18 Oct 2012 22:38:12 +0100 Subject: [PATCH 7/7] configure: fix libcdio check The compiler/linker flags passed to check_lib2 should not be quoted. Signed-off-by: Mans Rullgard --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 218e51301a..2bdc4b09f3 100755 --- a/configure +++ b/configure @@ -3377,7 +3377,7 @@ enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio enabled libcdio && - check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open "-lcdio_paranoia -lcdio_cdda -lcdio" + check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio enabled x11grab && require X11 X11/Xlib.h XOpenDisplay -lX11 &&