From 2ca6e9bb47f0f58f0cb4a840b301edf45e77f0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 25 Jun 2012 12:44:18 +0300 Subject: [PATCH 1/8] network: Extend the fallback gai_strerror implementation to handle more error codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is useful if a proper getaddrinfo is loaded dynamically on windows, while using the fallback implementation of gai_strerror. Signed-off-by: Martin Storsjö --- libavformat/network.h | 20 ++++++++++++++++++-- libavformat/os_support.c | 8 ++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/libavformat/network.h b/libavformat/network.h index 793cfee9a9..9b0b94de8b 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -110,17 +110,33 @@ struct addrinfo { #endif /* getaddrinfo constants */ +#ifndef EAI_AGAIN +#define EAI_AGAIN 2 +#endif +#ifndef EAI_BADFLAGS +#define EAI_BADFLAGS 3 +#endif #ifndef EAI_FAIL #define EAI_FAIL 4 #endif - #ifndef EAI_FAMILY #define EAI_FAMILY 5 #endif - +#ifndef EAI_MEMORY +#define EAI_MEMORY 6 +#endif +#ifndef EAI_NODATA +#define EAI_NODATA 7 +#endif #ifndef EAI_NONAME #define EAI_NONAME 8 #endif +#ifndef EAI_SERVICE +#define EAI_SERVICE 9 +#endif +#ifndef EAI_SOCKTYPE +#define EAI_SOCKTYPE 10 +#endif #ifndef AI_PASSIVE #define AI_PASSIVE 1 diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 6d8c8ac6a3..76204e0546 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -243,9 +243,17 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen, const char *ff_gai_strerror(int ecode) { switch(ecode) { + case EAI_AGAIN : return "Temporary failure in name resolution"; + case EAI_BADFLAGS: return "Invalid flags for ai_flags"; case EAI_FAIL : return "A non-recoverable error occurred"; case EAI_FAMILY : return "The address family was not recognized or the address length was invalid for the specified family"; + case EAI_MEMORY : return "Memory allocation failure"; +#if EAI_NODATA != EAI_NONAME + case EAI_NODATA : return "No address associated with hostname"; +#endif case EAI_NONAME : return "The name does not resolve for the supplied parameters"; + case EAI_SERVICE: return "servname not supported for ai_socktype"; + case EAI_SOCKTYPE: return "ai_socktype not supported"; } return "Unknown error"; From c98e2053f54483525c1098117b7443c522e0ede5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 18 Jun 2012 23:36:15 +0300 Subject: [PATCH 2/8] network: Undefine existing gai_strerror definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids warnings if there already exists a definition. This is the case on windows, where the getaddrinfo isn't available and linked to (and we use our fallbacks instead, which actually try to use the proper getaddrinfo version if found at runtime), but gai_strerror still exists as a define. Signed-off-by: Martin Storsjö --- libavformat/network.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/network.h b/libavformat/network.h index 9b0b94de8b..271f7451d8 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -181,6 +181,7 @@ const char *ff_gai_strerror(int ecode); #define getaddrinfo ff_getaddrinfo #define freeaddrinfo ff_freeaddrinfo #define getnameinfo ff_getnameinfo +#undef gai_strerror #define gai_strerror ff_gai_strerror #endif From 9e4b04f8b9bce79adeb6f7784619a93d5682d509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 25 Jun 2012 12:50:13 +0300 Subject: [PATCH 3/8] network: Always use our version of gai_strerror on windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even if linking directly to getaddrinfo, use our version of gai_strerror instead of the system's version. Microsoft explicitly documents that their version of gai_strerror is thread-unsafe. Signed-off-by: Martin Storsjö --- libavformat/network.h | 4 +++- libavformat/os_support.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/network.h b/libavformat/network.h index 271f7451d8..19c5a92256 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -177,10 +177,12 @@ void ff_freeaddrinfo(struct addrinfo *res); int ff_getnameinfo(const struct sockaddr *sa, int salen, char *host, int hostlen, char *serv, int servlen, int flags); -const char *ff_gai_strerror(int ecode); #define getaddrinfo ff_getaddrinfo #define freeaddrinfo ff_freeaddrinfo #define getnameinfo ff_getnameinfo +#endif +#if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H +const char *ff_gai_strerror(int ecode); #undef gai_strerror #define gai_strerror ff_gai_strerror #endif diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 76204e0546..9992a631c5 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -239,7 +239,9 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen, return 0; } +#endif /* !HAVE_GETADDRINFO */ +#if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H const char *ff_gai_strerror(int ecode) { switch(ecode) { @@ -258,7 +260,7 @@ const char *ff_gai_strerror(int ecode) return "Unknown error"; } -#endif +#endif /* !HAVE_GETADDRINFO || HAVE_WINSOCK2_H */ int ff_socket_nonblock(int socket, int enable) { From c37c383e595eac67d174e6ac596d6deba8c7cfd6 Mon Sep 17 00:00:00 2001 From: Mohammad Alsaleh Date: Sun, 15 Jul 2012 19:41:11 +0300 Subject: [PATCH 4/8] libfdk-aac: Check if cutoff value is valid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passing a cutoff value < sample_rate/256 will cause a crash. Also, values >20000 will have no effect and 20000 will be used anyway. Signed-off-by: Mohammad Alsaleh Signed-off-by: Martin Storsjö --- libavcodec/libfdk-aacenc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index b2bfad275e..f2c3fbdb73 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -231,6 +231,11 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) } if (avctx->cutoff > 0) { + if (avctx->cutoff < (avctx->sample_rate + 255) >> 8) { + av_log(avctx, AV_LOG_ERROR, "cutoff valid range is %d-20000\n", + (avctx->sample_rate + 255) >> 8); + goto error; + } if ((err = aacEncoder_SetParam(s->handle, AACENC_BANDWIDTH, avctx->cutoff)) != AACENC_OK) { av_log(avctx, AV_LOG_ERROR, "Unable to set the encoder bandwith to %d: %s\n", From 20d569dd61af16dc174a0ad6f437a883f29618ac Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 29 Jul 2011 12:01:22 +0200 Subject: [PATCH 5/8] mpeg: remove disabled code --- libavformat/mpeg.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index f0aed06864..ebaf3dbdf2 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -163,41 +163,6 @@ static int find_next_start_code(AVIOContext *pb, int *size_ptr, return val; } -#if 0 /* unused, remove? */ -/* XXX: optimize */ -static int find_prev_start_code(AVIOContext *pb, int *size_ptr) -{ - int64_t pos, pos_start; - int max_size, start_code; - - max_size = *size_ptr; - pos_start = avio_tell(pb); - - /* in order to go faster, we fill the buffer */ - pos = pos_start - 16386; - if (pos < 0) - pos = 0; - avio_seek(pb, pos, SEEK_SET); - avio_r8(pb); - - pos = pos_start; - for(;;) { - pos--; - if (pos < 0 || (pos_start - pos) >= max_size) { - start_code = -1; - goto the_end; - } - avio_seek(pb, pos, SEEK_SET); - start_code = avio_rb32(pb); - if ((start_code & 0xffffff00) == 0x100) - break; - } - the_end: - *size_ptr = pos_start - pos; - return start_code; -} -#endif - /** * Extract stream types from a program stream map * According to ISO/IEC 13818-1 ('MPEG-2 Systems') table 2-35 @@ -327,12 +292,6 @@ static int mpegps_read_pes_header(AVFormatContext *s, } } else if ((c & 0xc0) == 0x80) { /* mpeg 2 PES */ -#if 0 /* some streams have this field set for no apparent reason */ - if ((c & 0x30) != 0) { - /* Encrypted multiplex not handled */ - goto redo; - } -#endif flags = avio_r8(s->pb); header_len = avio_r8(s->pb); len -= 2; From 03d1b18e9633667ecf315c1ac804b015fb039e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 16 Jul 2012 01:00:21 +0300 Subject: [PATCH 6/8] configure: Remove an unused 'have' item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is only used for checking for a certain library, but the code doesn't need to know whether the function was found. Signed-off-by: Martin Storsjö --- configure | 1 - 1 file changed, 1 deletion(-) diff --git a/configure b/configure index 4973b1bd83..de2f4185a5 100755 --- a/configure +++ b/configure @@ -1063,7 +1063,6 @@ HAVE_LIST=" cbrtf closesocket cmov - CommandLineToArgvW cpuid dcbzl dev_bktr_ioctl_bt848_h From f06dee779438d85da6fc1eeca310fd8a19d3b5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 16 Jul 2012 01:11:18 +0300 Subject: [PATCH 7/8] configure: Move the getaddrinfo function check into the network block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the two checks (general vs winsock) fit in better. Signed-off-by: Martin Storsjö --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index de2f4185a5..6b46ee4e02 100755 --- a/configure +++ b/configure @@ -2836,6 +2836,7 @@ if enabled network; then check_type "sys/types.h sys/socket.h" "struct sockaddr_storage" check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len check_header netinet/sctp.h + check_func getaddrinfo $network_extralibs # Prefer arpa/inet.h over winsock2 if check_header arpa/inet.h ; then check_func closesocket @@ -2844,6 +2845,7 @@ if enabled network; then network_extralibs="-lws2" || \ { check_func_headers winsock2.h closesocket -lws2_32 && \ network_extralibs="-lws2_32"; } + check_func_headers ws2tcpip.h getaddrinfo $network_extralibs check_type ws2tcpip.h socklen_t check_type ws2tcpip.h "struct addrinfo" check_type ws2tcpip.h "struct group_source_req" @@ -2863,8 +2865,6 @@ check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; } check_func fcntl check_func fork -check_func getaddrinfo $network_extralibs || - check_func_headers ws2tcpip.h getaddrinfo $network_extralibs check_func gethrtime check_func getopt check_func getrusage From 08e087ccf7f7ef9b4e8c55b571bc779c0bc815b0 Mon Sep 17 00:00:00 2001 From: Jordi Ortiz Date: Tue, 3 Jul 2012 18:20:02 +0000 Subject: [PATCH 8/8] rtmp: rtmp_parse_result() add case for video and audio packets to avoid undesired debug output. Signed-off-by: Kostya Shishkov --- libavformat/rtmpproto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index b48274bdd8..5342be8dc4 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -959,6 +959,10 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) return ret; } break; + case RTMP_PT_VIDEO: + case RTMP_PT_AUDIO: + /* Audio and Video packets are parsed in get_packet() */ + break; default: av_log(s, AV_LOG_VERBOSE, "Unknown packet type received 0x%02X\n", pkt->type); break;