Commit 4da42ebe authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  MS Screen 1 decoder
  aacdec: Fix popping channel layouts.
  av_gettime: support Win32 without gettimeofday()
  Use av_gettime() in various places
  Move av_gettime() to libavutil
  dct-test: use emms_c() from libavutil instead of duplicating it
  mov: fix operator precedence bug
  mathematics.h: remove a couple of math defines
  Remove unnecessary inclusions of [sys/]time.h
  lavf: remove unnecessary inclusions of unistd.h
  bfin: libswscale: add const where appropriate to fix warnings
  bfin: libswscale: remove unnecessary #includes
  udp: Properly check for invalid sockets
  tcp: Check the return value from getsockopt
  network: Use av_strerror for getting error messages
  udp: Properly print error from getnameinfo
  mmst: Use AVUNERROR() to convert error codes to the right range for strerror
  network: Pass pointers of the right type to get/setsockopt/ioctlsocket on windows
  rtmp: Reduce the number of idle posts sent by sleeping 50ms

Conflicts:
	Changelog
	configure
	libavcodec/aacdec.c
	libavcodec/allcodecs.c
	libavcodec/avcodec.h
	libavcodec/dct-test.c
	libavcodec/version.h
	libavformat/riff.c
	libavformat/udp.c
	libavutil/Makefile
	libswscale/bfin/yuv2rgb_bfin.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents e632a430 005c80b6
......@@ -11,6 +11,7 @@ version next:
- ffprobe -show_data option
- RTMPT protocol support
- iLBC encoding/decoding via libilbc
- Microsoft Screen 1 decoder
- showwaves filter
......
......@@ -1206,7 +1206,9 @@ HAVE_LIST="
GetProcessAffinityMask
GetProcessMemoryInfo
GetProcessTimes
GetSystemTimeAsFileTime
getrusage
gettimeofday
glob
gnu_as
ibm_asm
......@@ -3142,6 +3144,7 @@ check_func getaddrinfo $network_extralibs
check_func gethrtime
check_func getrusage
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
check_func gettimeofday
check_func inet_aton $network_extralibs
check_func isatty
check_func localtime_r
......@@ -3163,6 +3166,7 @@ check_func_headers lzo/lzo1x.h lzo1x_999_compress
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
check_func_headers windows.h GetProcessAffinityMask
check_func_headers windows.h GetProcessTimes
check_func_headers windows.h GetSystemTimeAsFileTime
check_func_headers windows.h MapViewOfFile
check_func_headers windows.h VirtualAlloc
check_func_headers glob.h glob
......
......@@ -562,6 +562,8 @@ following image formats are supported:
@item LOCO @tab @tab X
@item lossless MJPEG @tab X @tab X
@item Microsoft RLE @tab @tab X
@item Microsoft Screen 1 @tab @tab X
@tab Also known as Windows Media Video V7 Screen.
@item Microsoft Video 1 @tab @tab X
@item Mimic @tab @tab X
@tab Used in MSN Messenger Webcam streams.
......
......@@ -63,7 +63,6 @@
#if HAVE_SYS_RESOURCE_H
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#elif HAVE_GETPROCESSTIMES
#include <windows.h>
......
......@@ -55,7 +55,6 @@
#include <poll.h>
#endif
#include <errno.h>
#include <sys/time.h>
#include <time.h>
#include <sys/wait.h>
#include <signal.h>
......
......@@ -327,6 +327,7 @@ OBJS-$(CONFIG_MSMPEG4V3_ENCODER) += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
h263dec.o h263.o ituh263dec.o \
mpeg4videodec.o
OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o msrledec.o
OBJS-$(CONFIG_MSS1_DECODER) += mss1.o
OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o
OBJS-$(CONFIG_MSVIDEO1_ENCODER) += msvideo1enc.o elbg.o
OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o
......
......@@ -170,6 +170,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2);
REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3);
REGISTER_DECODER (MSRLE, msrle);
REGISTER_DECODER (MSS1, mss1);
REGISTER_ENCDEC (MSVIDEO1, msvideo1);
REGISTER_DECODER (MSZH, mszh);
REGISTER_DECODER (MXPEG, mxpeg);
......
......@@ -257,6 +257,7 @@ enum CodecID {
CODEC_ID_CDXL,
CODEC_ID_XBM,
CODEC_ID_ZEROCODEC,
CODEC_ID_MSS1,
CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
CODEC_ID_EXR = MKBETAG('0','E','X','R'),
......
......@@ -28,13 +28,13 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <math.h>
#include "libavutil/cpu.h"
#include "libavutil/common.h"
#include "libavutil/lfg.h"
#include "libavutil/time.h"
#include "simple_idct.h"
#include "aandcttab.h"
......@@ -163,13 +163,6 @@ static const struct algo idct_tab[] = {
#define AANSCALE_BITS 12
static int64_t gettime(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
}
#define NB_ITS 20000
#define NB_ITS_SPEED 50000
......@@ -201,14 +194,6 @@ static void idct_mmx_init(void)
DECLARE_ALIGNED(16, static DCTELEM, block)[64];
DECLARE_ALIGNED(8, static DCTELEM, block1)[64];
static inline void mmx_emms(void)
{
#if HAVE_MMX
if (cpu_flags & AV_CPU_FLAG_MMX)
__asm__ volatile ("emms\n\t" ::: "memory");
#endif
}
static void init_block(DCTELEM block[64], int test, int is_idct, AVLFG *prng, int vals)
{
int i, j;
......@@ -287,7 +272,7 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
permute(block, block1, dct->format);
dct->func(block);
mmx_emms();
emms_c();
if (dct->format == SCALE_PERM) {
for (i = 0; i < 64; i++) {
......@@ -345,16 +330,16 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
init_block(block, test, is_idct, &prng, vals);
permute(block1, block, dct->format);
ti = gettime();
ti = av_gettime();
it1 = 0;
do {
for (it = 0; it < NB_ITS_SPEED; it++) {
memcpy(block, block1, sizeof(block));
dct->func(block);
}
mmx_emms();
emms_c();
it1 += NB_ITS_SPEED;
ti1 = gettime() - ti;
ti1 = av_gettime() - ti;
} while (ti1 < 1000000);
printf("%s %s: %0.1f kdct/s\n", is_idct ? "IDCT" : "DCT", dct->name,
......@@ -505,7 +490,7 @@ static void idct248_error(const char *name,
if (!speed)
return;
ti = gettime();
ti = av_gettime();
it1 = 0;
do {
for (it = 0; it < NB_ITS_SPEED; it++) {
......@@ -513,9 +498,9 @@ static void idct248_error(const char *name,
block[i] = block1[i];
idct248_put(img_dest, 8, block);
}
mmx_emms();
emms_c();
it1 += NB_ITS_SPEED;
ti1 = gettime() - ti;
ti1 = av_gettime() - ti;
} while (ti1 < 1000000);
printf("%s %s: %0.1f kdct/s\n", 1 ? "IDCT248" : "DCT248", name,
......
......@@ -27,6 +27,7 @@
#include "libavutil/mathematics.h"
#include "libavutil/lfg.h"
#include "libavutil/log.h"
#include "libavutil/time.h"
#include "fft.h"
#if CONFIG_FFT_FLOAT
#include "dct.h"
......@@ -34,7 +35,6 @@
#endif
#include <math.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
#include <string.h>
......@@ -186,13 +186,6 @@ static FFTSample frandom(AVLFG *prng)
return (int16_t)av_lfg_get(prng) / 32768.0 * RANGE;
}
static int64_t gettime(void)
{
struct timeval tv;
gettimeofday(&tv,NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
}
static int check_diff(FFTSample *tab1, FFTSample *tab2, int n, double scale)
{
int i;
......@@ -430,7 +423,7 @@ int main(int argc, char **argv)
/* we measure during about 1 seconds */
nb_its = 1;
for(;;) {
time_start = gettime();
time_start = av_gettime();
for (it = 0; it < nb_its; it++) {
switch (transform) {
case TRANSFORM_MDCT:
......@@ -456,7 +449,7 @@ int main(int argc, char **argv)
#endif
}
}
duration = gettime() - time_start;
duration = av_gettime() - time_start;
if (duration >= 1000000)
break;
nb_its *= 2;
......
......@@ -32,6 +32,7 @@
#include "config.h"
#include "dsputil.h"
#include "libavutil/lfg.h"
#include "libavutil/time.h"
#undef printf
......@@ -58,13 +59,6 @@ static void help(void)
"test motion implementations\n");
}
static int64_t gettime(void)
{
struct timeval tv;
gettimeofday(&tv,NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
}
#define NB_ITS 500
int dummy;
......@@ -97,7 +91,7 @@ static void test_motion(const char *name,
emms_c();
/* speed test */
ti = gettime();
ti = av_gettime();
d1 = 0;
for(it=0;it<NB_ITS;it++) {
for(y=0;y<HEIGHT-17;y++) {
......@@ -109,7 +103,7 @@ static void test_motion(const char *name,
}
emms_c();
dummy = d1; /* avoid optimization */
ti = gettime() - ti;
ti = av_gettime() - ti;
printf(" %0.0f kop/s\n",
(double)NB_ITS * (WIDTH - 16) * (HEIGHT - 16) /
......
This diff is collapsed.
......@@ -27,7 +27,7 @@
*/
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 26
#define LIBAVCODEC_VERSION_MINOR 27
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
......@@ -26,8 +26,6 @@
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <time.h>
#include "libavutil/log.h"
#include "libavutil/opt.h"
......
......@@ -32,7 +32,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <time.h>
#include <linux/fb.h>
......
......@@ -33,8 +33,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/select.h>
#include "libavutil/log.h"
#include "libavutil/opt.h"
......
......@@ -46,7 +46,6 @@
#endif
#include <linux/videodev2.h>
#endif
#include <time.h>
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
......
......@@ -1854,10 +1854,9 @@ void av_dump_format(AVFormatContext *ic,
const char *url,
int is_output);
/**
* Get the current time in microseconds.
*/
#if FF_API_AV_GETTIME
int64_t av_gettime(void);
#endif
/**
* Return in 'buf' the path with '%d' replaced by a number.
......
......@@ -21,7 +21,6 @@
#include "libavutil/avstring.h"
#include "avformat.h"
#include <unistd.h>
#include "internal.h"
#include "network.h"
#include "http.h"
......
......@@ -144,7 +144,7 @@ static int send_command_packet(MMSTContext *mmst)
av_log(NULL, AV_LOG_ERROR,
"Failed to write data of length %d: %d (%s)\n",
exact_length, write_result,
write_result < 0 ? strerror(write_result) :
write_result < 0 ? strerror(AVUNERROR(write_result)) :
"The server closed the connection");
return AVERROR(EIO);
}
......@@ -246,7 +246,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
if(read_result < 0) {
av_log(NULL, AV_LOG_ERROR,
"Error reading packet header: %d (%s)\n",
read_result, strerror(read_result));
read_result, strerror(AVUNERROR(read_result)));
packet_type = SC_PKT_CANCEL;
} else {
av_log(NULL, AV_LOG_ERROR,
......@@ -266,7 +266,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
av_log(NULL, AV_LOG_ERROR,
"Reading command packet length failed: %d (%s)\n",
read_result,
read_result < 0 ? strerror(read_result) :
read_result < 0 ? strerror(AVUNERROR(read_result)) :
"The server closed the connection");
return read_result < 0 ? read_result : AVERROR(EIO);
}
......@@ -287,7 +287,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
av_log(NULL, AV_LOG_ERROR,
"Reading pkt data (length=%d) failed: %d (%s)\n",
length_remaining, read_result,
read_result < 0 ? strerror(read_result) :
read_result < 0 ? strerror(AVUNERROR(read_result)) :
"The server closed the connection");
return read_result < 0 ? read_result : AVERROR(EIO);
}
......@@ -324,7 +324,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
av_log(NULL, AV_LOG_ERROR,
"Failed to read packet data of size %d: %d (%s)\n",
length_remaining, read_result,
read_result < 0 ? strerror(read_result) :
read_result < 0 ? strerror(AVUNERROR(read_result)) :
"The server closed the connection");
return read_result < 0 ? read_result : AVERROR(EIO);
}
......
......@@ -1087,7 +1087,7 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR_INVALIDDATA;
profile_level = avio_r8(pb);
if (profile_level & 0xf0 != 0xc0)
if ((profile_level & 0xf0) != 0xc0)
return 0;
av_free(st->codec->extradata);
......
......@@ -47,6 +47,8 @@
# undef EINPROGRESS
#endif
#define EINPROGRESS WSAEINPROGRESS
#define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e)
#define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e)
int ff_neterrno(void);
#else
......
......@@ -58,7 +58,6 @@ int ff_win32_open(const char *filename_utf8, int oflag, int pmode)
#if CONFIG_NETWORK
#include <fcntl.h>
#include <unistd.h>
#if !HAVE_POLL_H
#include <sys/time.h>
#if HAVE_WINSOCK2_H
......@@ -253,7 +252,8 @@ const char *ff_gai_strerror(int ecode)
int ff_socket_nonblock(int socket, int enable)
{
#if HAVE_WINSOCK2_H
return ioctlsocket(socket, FIONBIO, &enable);
u_long param = enable;
return ioctlsocket(socket, FIONBIO, &param);
#else
if (enable)
return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
......
......@@ -307,6 +307,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_Y41P, MKTAG('Y', '4', '1', 'P') },
{ CODEC_ID_FLIC, MKTAG('A', 'F', 'L', 'C') },
{ CODEC_ID_EXR, MKTAG('e', 'x', 'r', ' ') },
{ CODEC_ID_MSS1, MKTAG('M', 'S', 'S', '1') },
{ CODEC_ID_NONE, 0 }
};
......
......@@ -24,6 +24,8 @@
* RTMP HTTP protocol
*/
#include <unistd.h>
#include "libavutil/avstring.h"
#include "libavutil/intfloat.h"
#include "libavutil/opt.h"
......@@ -44,6 +46,7 @@ typedef struct RTMP_HTTPContext {
int out_capacity; ///< current output buffer capacity
int initialized; ///< flag indicating when the http context is initialized
int finishing; ///< flag indicating when the client closes the connection
int nb_bytes_read; ///< number of bytes read since the last request
} RTMP_HTTPContext;
static int rtmp_http_send_cmd(URLContext *h, const char *cmd)
......@@ -70,6 +73,9 @@ static int rtmp_http_send_cmd(URLContext *h, const char *cmd)
if ((ret = ffurl_read(rt->stream, &c, 1)) < 0)
return ret;
/* re-init the number of bytes read */
rt->nb_bytes_read = 0;
return ret;
}
......@@ -117,6 +123,12 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size)
if ((ret = rtmp_http_send_cmd(h, "send")) < 0)
return ret;
} else {
if (rt->nb_bytes_read == 0) {
/* Wait 50ms before retrying to read a server reply in
* order to reduce the number of idle requets. */
usleep(50000);
}
if ((ret = rtmp_http_write(h, "", 1)) < 0)
return ret;
......@@ -131,6 +143,7 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size)
} else {
off += ret;
size -= ret;
rt->nb_bytes_read += ret;
}
} while (off <= 0);
......
......@@ -39,7 +39,6 @@
#include "avformat.h"
#include "mpegts.h"
#include <unistd.h>
#include "network.h"
#include <assert.h>
......
......@@ -31,7 +31,6 @@
#include "rtpdec.h"
#include "url.h"
#include <unistd.h>
#include <stdarg.h>
#include "internal.h"
#include "network.h"
......@@ -40,7 +39,6 @@
#if HAVE_POLL_H
#include <sys/poll.h>
#endif
#include <sys/time.h>
#define RTP_TX_BUF_SIZE (64 * 1024)
#define RTP_RX_BUF_SIZE (128 * 1024)
......
......@@ -30,7 +30,6 @@
#include "avformat.h"
#include "avio_internal.h"
#include <sys/time.h>
#if HAVE_POLL_H
#include <poll.h>
#endif
......
......@@ -21,7 +21,6 @@
#include "avformat.h"
#include <sys/time.h>
#if HAVE_POLL_H
#include <poll.h>
#endif
......
......@@ -30,7 +30,6 @@
#if HAVE_POLL_H
#include <poll.h>
#endif
#include <sys/time.h>
struct SAPState {
URLContext *ann_fd;
......
......@@ -39,7 +39,6 @@
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <sys/time.h>
#include <unistd.h>
#include "config.h"
......
......@@ -28,7 +28,6 @@
#if HAVE_POLL_H
#include <poll.h>
#endif
#include <sys/time.h>
typedef struct TCPContext {
int fd;
......@@ -139,12 +138,15 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
}
/* test error */
optlen = sizeof(ret);
getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen);
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))
ret = AVUNERROR(ff_neterrno());
if (ret != 0) {
char errbuf[100];
ret = AVERROR(ret);
av_strerror(ret, errbuf, sizeof(errbuf));
av_log(h, AV_LOG_ERROR,
"TCP connection to %s:%d failed: %s\n",
hostname, port, strerror(ret));
ret = AVERROR(ret);
hostname, port, errbuf);
goto fail;
}
}
......
......@@ -42,8 +42,6 @@
#include <pthread.h>
#endif
#include <sys/time.h>
#ifndef IPV6_ADD_MEMBERSHIP
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
......@@ -78,13 +76,20 @@ typedef struct {
int remaining_in_dg;
} UDPContext;
static void log_net_error(void *ctx, int level, const char* prefix)
{
char errbuf[100];
av_strerror(ff_neterrno(), errbuf, sizeof(errbuf));
av_log(ctx, level, "%s: %s\n", prefix, errbuf);
}
static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
struct sockaddr *addr)
{
#ifdef IP_MULTICAST_TTL
if (addr->sa_family == AF_INET) {
if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) {
av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL): %s\n", strerror(errno));
log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)");
return -1;
}
}
......@@ -92,7 +97,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
#if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS)
if (addr->sa_family == AF_INET6) {
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) {
av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS): %s\n", strerror(errno));
log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)");
return -1;
}
}
......@@ -109,7 +114,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr)
mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
mreq.imr_interface.s_addr= INADDR_ANY;
if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP): %s\n", strerror(errno));
log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)");
return -1;
}
}
......@@ -121,7 +126,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr)
memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr));
mreq6.ipv6mr_interface= 0;
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP): %s\n", strerror(errno));
log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)");
return -1;
}
}
......@@ -138,7 +143,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr)
mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
mreq.imr_interface.s_addr= INADDR_ANY;
if (setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP): %s\n", strerror(errno));
log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP)");
return -1;
}
}
......@@ -150,7 +155,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr)
memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr));
mreq6.ipv6mr_interface= 0;
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP): %s\n", strerror(errno));
log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP)");
return -1;
}
}
......@@ -214,8 +219,8 @@ static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr,
goto fail;
for (res = res0; res; res=res->ai_next) {
udp_fd = socket(res->ai_family, SOCK_DGRAM, 0);
if (udp_fd > 0) break;
av_log(NULL, AV_LOG_ERROR, "socket: %s\n", strerror(errno));
if (udp_fd != -1) break;
log_net_error(NULL, AV_LOG_ERROR, "socket");
}
if (udp_fd < 0)
......@@ -239,9 +244,10 @@ static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr,
static int udp_port(struct sockaddr_storage *addr, int addr_len)
{
char sbuf[sizeof(int)*3+1];
int error;
if (getnameinfo((struct sockaddr *)addr, addr_len, NULL, 0, sbuf, sizeof(sbuf), NI_NUMERICSERV) != 0) {
av_log(NULL, AV_LOG_ERROR, "getnameinfo: %s\n", strerror(errno));
if ((error = getnameinfo((struct sockaddr *)addr, addr_len, NULL, 0, sbuf, sizeof(sbuf), NI_NUMERICSERV)) != 0) {
av_log(NULL, AV_LOG_ERROR, "getnameinfo: %s\n", gai_strerror(error));
return -1;
}
......@@ -289,7 +295,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(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
log_net_error(h, AV_LOG_ERROR, "connect");
return AVERROR(EIO);
}
}
......@@ -479,7 +485,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
* bind failed */
/* the bind is needed to give a port to the socket now */
if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
av_log(h, AV_LOG_ERROR, "bind failed: %s\n", strerror(errno));
log_net_error(h, AV_LOG_ERROR, "bind failed");
goto fail;
}
......@@ -504,7 +510,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(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
log_net_error(h, AV_LOG_ERROR, "setsockopt(SO_SNDBUF)");
goto fail;
}
} else {
......@@ -512,14 +518,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(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_RECVBUF)");
}
/* 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(h, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
log_net_error(h, AV_LOG_ERROR, "connect");
goto fail;
}
}
......
......@@ -41,8 +41,6 @@
#include "riff.h"
#include "audiointerleave.h"
#include "url.h"
#include <sys/time.h>
#include <time.h>
#include <stdarg.h>
#if CONFIG_NETWORK
#include "network.h"
......@@ -3875,12 +3873,12 @@ void av_dump_format(AVFormatContext *ic,
av_free(printed);
}
int64_t av_gettime(void)
#if FF_API_AV_GETTIME && CONFIG_SHARED && HAVE_SYMVER
FF_SYMVER(int64_t, av_gettime, (void), "LIBAVFORMAT_54")
{
struct timeval tv;
gettimeofday(&tv,NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
return av_gettime();
}
#endif
uint64_t ff_ntp_time(void)
{
......
......@@ -77,5 +77,8 @@
#ifndef FF_API_INTERLEAVE_PACKET
#define FF_API_INTERLEAVE_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
#endif
#ifndef FF_API_AV_GETTIME
#define FF_API_AV_GETTIME (LIBAVFORMAT_VERSION_MAJOR < 55)
#endif
#endif /* AVFORMAT_VERSION_H */
......@@ -39,6 +39,7 @@ HEADERS = adler32.h \
rational.h \
samplefmt.h \
sha.h \
time.h \
timecode.h \
timestamp.h \
......@@ -83,6 +84,7 @@ OBJS = adler32.o \
rc4.o \
samplefmt.o \
sha.o \
time.o \
timecode.o \
tree.o \
utils.o \
......
......@@ -343,7 +343,7 @@ void av_des_mac(AVDES *d, uint8_t *dst, const uint8_t *src, int count) {
#undef srand
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include "libavutil/time.h"
static uint64_t rand64(void) {
uint64_t r = rand();
r = (r << 32) | rand();
......@@ -390,13 +390,11 @@ int main(void) {
#ifdef GENTABLES
int j;
#endif
struct timeval tv;
uint64_t key[3];
uint64_t data;
uint64_t ct;
uint64_t roundkeys[16];
gettimeofday(&tv, NULL);
srand(tv.tv_sec * 1000 * 1000 + tv.tv_usec);
srand(av_gettime());
key[0] = AV_RB64(test_key);
data = AV_RB64(plain);
gen_roundkeys(roundkeys, key[0]);
......
......@@ -26,30 +26,12 @@
#include "attributes.h"
#include "rational.h"
#ifndef M_E
#define M_E 2.7182818284590452354 /* e */
#endif
#ifndef M_LN2
#define M_LN2 0.69314718055994530942 /* log_e 2 */
#endif
#ifndef M_LN10
#define M_LN10 2.30258509299404568402 /* log_e 10 */
#endif
#ifndef M_LOG2_10
#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */
#endif
#ifndef M_PHI
#define M_PHI 1.61803398874989484820 /* phi / golden ratio */
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
#ifndef M_SQRT1_2
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#endif
#ifndef NAN
#define NAN (0.0/0.0)
#endif
......
......@@ -21,7 +21,6 @@
* misc parsing utilities
*/
#include <sys/time.h>
#include <time.h>
#include "avstring.h"
......
/*
* 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 "config.h"
#include <stddef.h>
#include <stdint.h>
#if HAVE_GETTIMEOFDAY
#include <sys/time.h>
#elif HAVE_GETSYSTEMTIMEASFILETIME
#include <windows.h>
#endif
#include "libavutil/time.h"
int64_t av_gettime(void)
{
#if HAVE_GETTIMEOFDAY
struct timeval tv;
gettimeofday(&tv, NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
#elif HAVE_GETSYSTEMTIMEASFILETIME
FILETIME ft;
int64_t t;
GetSystemTimeAsFileTime(&ft);
t = (int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime;
return t / 10 - 11644473600000000; /* Jan 1, 1601 */
#else
return -1;
#endif
}
/*
* 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_TIME_H
#define AVUTIL_TIME_H
#include <stdint.h>
/**
* Get the current time in microseconds.
*/
int64_t av_gettime(void);
#endif /* AVUTIL_TIME_H */
......@@ -20,16 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include "config.h"
#include <unistd.h>
#include <stdint.h>
#include "libswscale/rgb2rgb.h"
#include "libswscale/swscale.h"
#include "config.h"
#include "libswscale/swscale_internal.h"
#if defined (__FDPIC__) && CONFIG_SRAM
......@@ -46,14 +39,14 @@ int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
uint8_t *vdst, int width, int height,
int lumStride, int chromStride, int srcStride) L1CODE;
static int uyvytoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
int srcSliceY, int srcSliceH, uint8_t *dst[],
int dstStride[])
static int uyvytoyv12_unscaled(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY, int srcSliceH,
uint8_t *dst[], int dstStride[])
{
uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
const uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
int w = dstStride[0];
ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
......@@ -62,14 +55,14 @@ static int uyvytoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
return srcSliceH;
}
static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
int srcSliceY, int srcSliceH, uint8_t *dst[],
int dstStride[])
static int yuyvtoyv12_unscaled(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY, int srcSliceH,
uint8_t *dst[], int dstStride[])
{
uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
const uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
int w = dstStride[0];
ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
......
......@@ -21,17 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include <unistd.h>
#include "libavutil/pixdesc.h"
#include <stdint.h>
#include "config.h"
#include "libswscale/rgb2rgb.h"
#include "libswscale/swscale.h"
#include "libswscale/swscale_internal.h"
#if defined(__FDPIC__) && CONFIG_SRAM
......@@ -40,17 +33,20 @@
#define L1CODE
#endif
void ff_bfin_yuv2rgb555_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
void ff_bfin_yuv2rgb555_line(const uint8_t *Y, const uint8_t *U,
const uint8_t *V, uint8_t *out,
int w, uint32_t *coeffs) L1CODE;
void ff_bfin_yuv2rgb565_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
void ff_bfin_yuv2rgb565_line(const uint8_t *Y, const uint8_t *U,
const uint8_t *V, uint8_t *out,
int w, uint32_t *coeffs) L1CODE;
void ff_bfin_yuv2rgb24_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
void ff_bfin_yuv2rgb24_line(const uint8_t *Y, const uint8_t *U,
const uint8_t *V, uint8_t *out,
int w, uint32_t *coeffs) L1CODE;
typedef void (*ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
int w, uint32_t *coeffs);
typedef void (*ltransform)(const uint8_t *Y, const uint8_t *U, const uint8_t *V,
uint8_t *out, int w, uint32_t *coeffs);
static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks)
{
......@@ -88,12 +84,13 @@ static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks)
}
}
static int core_yuv420_rgb(SwsContext *c, uint8_t **in, int *instrides,
static int core_yuv420_rgb(SwsContext *c, const uint8_t **in, int *instrides,
int srcSliceY, int srcSliceH, uint8_t **oplanes,
int *outstrides, ltransform lcscf,
int rgb, int masks)
{
uint8_t *py, *pu, *pv, *op;
const uint8_t *py, *pu, *pv;
uint8_t *op;
int w = instrides[0];
int h2 = srcSliceH >> 1;
int i;
......@@ -123,7 +120,7 @@ static int core_yuv420_rgb(SwsContext *c, uint8_t **in, int *instrides,
return srcSliceH;
}
static int bfin_yuv420_rgb555(SwsContext *c, uint8_t **in, int *instrides,
static int bfin_yuv420_rgb555(SwsContext *c, const uint8_t **in, int *instrides,
int srcSliceY, int srcSliceH,
uint8_t **oplanes, int *outstrides)
{
......@@ -131,7 +128,7 @@ static int bfin_yuv420_rgb555(SwsContext *c, uint8_t **in, int *instrides,
outstrides, ff_bfin_yuv2rgb555_line, 1, 555);
}
static int bfin_yuv420_bgr555(SwsContext *c, uint8_t **in, int *instrides,
static int bfin_yuv420_bgr555(SwsContext *c, const uint8_t **in, int *instrides,
int srcSliceY, int srcSliceH,
uint8_t **oplanes, int *outstrides)
{
......@@ -139,7 +136,7 @@ static int bfin_yuv420_bgr555(SwsContext *c, uint8_t **in, int *instrides,
outstrides, ff_bfin_yuv2rgb555_line, 0, 555);
}
static int bfin_yuv420_rgb24(SwsContext *c, uint8_t **in, int *instrides,
static int bfin_yuv420_rgb24(SwsContext *c, const uint8_t **in, int *instrides,
int srcSliceY, int srcSliceH,
uint8_t **oplanes, int *outstrides)
{
......@@ -147,7 +144,7 @@ static int bfin_yuv420_rgb24(SwsContext *c, uint8_t **in, int *instrides,
outstrides, ff_bfin_yuv2rgb24_line, 1, 888);
}
static int bfin_yuv420_bgr24(SwsContext *c, uint8_t **in, int *instrides,
static int bfin_yuv420_bgr24(SwsContext *c, const uint8_t **in, int *instrides,
int srcSliceY, int srcSliceH,
uint8_t **oplanes, int *outstrides)
{
......@@ -155,7 +152,7 @@ static int bfin_yuv420_bgr24(SwsContext *c, uint8_t **in, int *instrides,
outstrides, ff_bfin_yuv2rgb24_line, 0, 888);
}
static int bfin_yuv420_rgb565(SwsContext *c, uint8_t **in, int *instrides,
static int bfin_yuv420_rgb565(SwsContext *c, const uint8_t **in, int *instrides,
int srcSliceY, int srcSliceH,
uint8_t **oplanes, int *outstrides)
{
......@@ -163,7 +160,7 @@ static int bfin_yuv420_rgb565(SwsContext *c, uint8_t **in, int *instrides,
outstrides, ff_bfin_yuv2rgb565_line, 1, 565);
}
static int bfin_yuv420_bgr565(SwsContext *c, uint8_t **in, int *instrides,
static int bfin_yuv420_bgr565(SwsContext *c, const uint8_t **in, int *instrides,
int srcSliceY, int srcSliceH,
uint8_t **oplanes, int *outstrides)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment