From 78e99e0f32b610a3cf302b2b35e500f4e9eaff07 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 22 Mar 2011 22:38:44 +0100 Subject: Do not use format string "%0.3f" for RTSP Range field. The format string was locale-depending. Signed-off-by: Ronald S. Bultje --- libavformat/rtspdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libavformat') diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index ac1f22043f..571e76dfa9 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -60,8 +60,9 @@ static int rtsp_read_play(AVFormatContext *s) cmd[0] = 0; } else { snprintf(cmd, sizeof(cmd), - "Range: npt=%0.3f-\r\n", - (double)rt->seek_timestamp / AV_TIME_BASE); + "Range: npt=%"PRId64".%03"PRId64"-\r\n", + rt->seek_timestamp / AV_TIME_BASE, + rt->seek_timestamp / (AV_TIME_BASE / 1000) % 1000); } ff_rtsp_send_cmd(s, "PLAY", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) { -- cgit v1.2.3 From bc17bd90f51a6eb464746b2d5144e1ec57ca4bfb Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Mar 2011 09:05:36 +0100 Subject: matroskaenc: simplify get_aac_sample_rates by using ff_mpeg4audio_get_config This also fixes broken SBR detection, which produced files with double sample rate since 8ae0fa2. Signed-off-by: Ronald S. Bultje --- libavformat/matroskaenc.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'libavformat') diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index fba7dbc564..0ab1832cb7 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -439,28 +439,15 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int *sample_rate, int *output_sample_rate) { int sri; + MPEG4AudioConfig mp4ac; - if (codec->extradata_size < 2) { - av_log(s, AV_LOG_WARNING, "No AAC extradata, unable to determine samplerate.\n"); + if (ff_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { + av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n"); return; } - sri = ((codec->extradata[0] << 1) & 0xE) | (codec->extradata[1] >> 7); - if (sri > 12) { - av_log(s, AV_LOG_WARNING, "AAC samplerate index out of bounds\n"); - return; - } - *sample_rate = ff_mpeg4audio_sample_rates[sri]; - - // if sbr, get output sample rate as well - if (codec->extradata_size == 5) { - sri = (codec->extradata[4] >> 3) & 0xF; - if (sri > 12) { - av_log(s, AV_LOG_WARNING, "AAC output samplerate index out of bounds\n"); - return; - } - *output_sample_rate = ff_mpeg4audio_sample_rates[sri]; - } + *sample_rate = mp4ac.sample_rate; + *output_sample_rate = mp4ac.ext_sample_rate; } static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int native_id, int qt_id) -- cgit v1.2.3 From 1b7ecc1662956fc30d20bdcdbc0617127b2976cc Mon Sep 17 00:00:00 2001 From: Tomas Härdin Date: Mon, 21 Mar 2011 12:06:56 +0100 Subject: Add xd55 codec tag for XDCAM HD422 720p25 CBR files. Signed-off-by: Ronald S. Bultje --- libavformat/isom.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libavformat') diff --git a/libavformat/isom.c b/libavformat/isom.c index 6c380c1a12..c65f9317e7 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -157,6 +157,7 @@ const AVCodecTag codec_movvideo_tags[] = { { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'n') }, /* MPEG2 IMX NTSC 525/60 30mb/s produced by FCP */ { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'p') }, /* MPEG2 IMX PAL 625/50 30mb/s produced by FCP */ { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '4') }, /* XDCAM HD422 720p24 CBR */ + { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '5') }, /* XDCAM HD422 720p25 CBR */ { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '9') }, /* XDCAM HD422 720p60 CBR */ { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'a') }, /* XDCAM HD422 720p50 CBR */ { CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', 'b') }, /* XDCAM HD422 1080i60 CBR */ -- cgit v1.2.3 From 28e9c42afbf0088aa1f4280a95d304dca4b675a0 Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Wed, 23 Mar 2011 10:26:22 +0200 Subject: rtsp: Don't use a locale dependent format string In this particular case, we aren't ever printing anything else than 0.000 anyway. Signed-off-by: Ronald S. Bultje --- libavformat/rtspenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libavformat') diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index c163f4ce68..1f1fd32fc1 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -103,8 +103,7 @@ static int rtsp_write_record(AVFormatContext *s) char cmd[1024]; snprintf(cmd, sizeof(cmd), - "Range: npt=%0.3f-\r\n", - (double) 0); + "Range: npt=0.000-\r\n"); ff_rtsp_send_cmd(s, "RECORD", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return -1; -- cgit v1.2.3 From 491653ed90e12feefada217a59af9cd69cc7ca31 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 23 Mar 2011 11:58:02 +0000 Subject: avio: cosmetics - nicer vertical alignment. Signed-off-by: Mans Rullgard --- libavformat/avio.h | 2 +- libavformat/avio_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libavformat') diff --git a/libavformat/avio.h b/libavformat/avio.h index 753fa0cc89..d11c3984f8 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -416,7 +416,7 @@ attribute_deprecated void put_tag(AVIOContext *s, const char *tag); */ attribute_deprecated int av_url_read_fpause(AVIOContext *h, int pause); -attribute_deprecated int64_t av_url_read_fseek( AVIOContext *h, int stream_index, +attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_index, int64_t timestamp, int flags); /** diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 7dd9bdf6a0..406101618e 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -67,7 +67,7 @@ uint64_t ffio_read_varlen(AVIOContext *bc); int ffio_set_buf_size(AVIOContext *s, int buf_size); int ffio_read_pause(AVIOContext *h, int pause); -int64_t ffio_read_seek( AVIOContext *h, int stream_index, +int64_t ffio_read_seek (AVIOContext *h, int stream_index, int64_t timestamp, int flags); -- cgit v1.2.3 From 264935c96212c922e63c1fdb3c6ebf0bfce5c45d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 23 Mar 2011 11:09:34 +0100 Subject: matroskaenc: remove a variable that's unused after bc17bd9. Signed-off-by: Ronald S. Bultje --- libavformat/matroskaenc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'libavformat') diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 0ab1832cb7..4f9bf0a723 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -438,7 +438,6 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int *sample_rate, int *output_sample_rate) { - int sri; MPEG4AudioConfig mp4ac; if (ff_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { -- cgit v1.2.3 From 4377fafda100117f75d62ba91bce6d8509e01a50 Mon Sep 17 00:00:00 2001 From: Vladimir Pantelic Date: Thu, 17 Mar 2011 22:34:52 +0100 Subject: asfdec: also subtract preroll when reading simple index object This was missed when ASF was changed to return timestamps without preroll. Signed-off-by: Mans Rullgard --- libavformat/asfdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libavformat') diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 15dc55b823..14ef2a5c37 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1219,10 +1219,10 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index) int pktnum=avio_rl32(s->pb); int pktct =avio_rl16(s->pb); int64_t pos = s->data_offset + s->packet_size*(int64_t)pktnum; - int64_t index_pts= av_rescale(itime, i, 10000); + int64_t index_pts= FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0); if(pos != last_pos){ - av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d\n", pktnum, pktct); + av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n", pktnum, pktct, index_pts); av_add_index_entry(s->streams[stream_index], pos, index_pts, s->packet_size, 0, AVINDEX_KEYFRAME); last_pos=pos; } -- cgit v1.2.3 From 4ec153bb66a95da46c98e269bd0aa787e6172ed3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 8 Mar 2011 10:35:52 +0100 Subject: avio: make udp_set_remote_url/get_local_port internal. --- doc/protocols.texi | 4 ++-- libavformat/avio.h | 6 +++--- libavformat/avio_internal.h | 4 ++++ libavformat/rtpproto.c | 11 ++++++----- libavformat/udp.c | 7 ++++--- 5 files changed, 19 insertions(+), 13 deletions(-) (limited to 'libavformat') diff --git a/doc/protocols.texi b/doc/protocols.texi index a17d66362a..83c238f346 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -433,9 +433,9 @@ set the time to live value (for multicast only) @item connect=@var{1|0} Initialize the UDP socket with @code{connect()}. In this case, the -destination address can't be changed with udp_set_remote_url later. +destination address can't be changed with ff_udp_set_remote_url later. If the destination address isn't known at the start, this option can -be specified in udp_set_remote_url, too. +be specified in ff_udp_set_remote_url, too. This allows finding out the source address for the packets with getsockname, and makes writes return with AVERROR(ECONNREFUSED) if "destination unreachable" is received. diff --git a/libavformat/avio.h b/libavformat/avio.h index d11c3984f8..07a893e312 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -448,6 +448,9 @@ attribute_deprecated void put_flush_packet(AVIOContext *s); */ attribute_deprecated int url_feof(AVIOContext *s); attribute_deprecated int url_ferror(AVIOContext *s); + +attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri); +attribute_deprecated int udp_get_local_port(URLContext *h); #endif AVIOContext *avio_alloc_context( @@ -675,9 +678,6 @@ void init_checksum(AVIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum); -/* udp.c */ -int udp_set_remote_url(URLContext *h, const char *uri); -int udp_get_local_port(URLContext *h); #if FF_API_UDP_GET_FILE int udp_get_file_handle(URLContext *h); #endif diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 406101618e..6eee947383 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -70,5 +70,9 @@ int ffio_read_pause(AVIOContext *h, int pause); int64_t ffio_read_seek (AVIOContext *h, int stream_index, int64_t timestamp, int flags); +/* udp.c */ +int ff_udp_set_remote_url(URLContext *h, const char *uri); +int ff_udp_get_local_port(URLContext *h); + #endif // AVFORMAT_AVIO_INTERNAL_H diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 7b86c2f8bb..6b537c88ec 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -27,6 +27,7 @@ #include "libavutil/parseutils.h" #include "libavutil/avstring.h" #include "avformat.h" +#include "avio_internal.h" #include "rtpdec.h" #include @@ -71,10 +72,10 @@ int rtp_set_remote_url(URLContext *h, const char *uri) path, sizeof(path), uri); ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path); - udp_set_remote_url(s->rtp_hd, buf); + ff_udp_set_remote_url(s->rtp_hd, buf); ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port + 1, "%s", path); - udp_set_remote_url(s->rtcp_hd, buf); + ff_udp_set_remote_url(s->rtcp_hd, buf); return 0; } @@ -191,7 +192,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) if (url_open(&s->rtp_hd, buf, flags) < 0) goto fail; if (local_rtp_port>=0 && local_rtcp_port<0) - local_rtcp_port = udp_get_local_port(s->rtp_hd) + 1; + local_rtcp_port = ff_udp_get_local_port(s->rtp_hd) + 1; build_udp_url(buf, sizeof(buf), hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size, @@ -326,7 +327,7 @@ static int rtp_close(URLContext *h) int rtp_get_local_rtp_port(URLContext *h) { RTPContext *s = h->priv_data; - return udp_get_local_port(s->rtp_hd); + return ff_udp_get_local_port(s->rtp_hd); } /** @@ -338,7 +339,7 @@ int rtp_get_local_rtp_port(URLContext *h) int rtp_get_local_rtcp_port(URLContext *h) { RTPContext *s = h->priv_data; - return udp_get_local_port(s->rtcp_hd); + return ff_udp_get_local_port(s->rtcp_hd); } static int rtp_get_file_handle(URLContext *h) diff --git a/libavformat/udp.c b/libavformat/udp.c index 660229810d..8d50218f19 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -27,6 +27,7 @@ #define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */ #define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */ #include "avformat.h" +#include "avio_internal.h" #include "libavutil/parseutils.h" #include #include "internal.h" @@ -243,7 +244,7 @@ static int udp_port(struct sockaddr_storage *addr, int addr_len) * @param uri of the remote server * @return zero if no error. */ -int udp_set_remote_url(URLContext *h, const char *uri) +int ff_udp_set_remote_url(URLContext *h, const char *uri) { UDPContext *s = h->priv_data; char hostname[256], buf[10]; @@ -282,7 +283,7 @@ int udp_set_remote_url(URLContext *h, const char *uri) * @param h media file context * @return the local port number */ -int udp_get_local_port(URLContext *h) +int ff_udp_get_local_port(URLContext *h) { UDPContext *s = h->priv_data; return s->local_port; @@ -365,7 +366,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) if (flags & URL_WRONLY) goto fail; } else { - if (udp_set_remote_url(h, uri) < 0) + if (ff_udp_set_remote_url(h, uri) < 0) goto fail; } -- cgit v1.2.3