Commit ec794685 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  rtpdec_jpeg: Add support for default quantizers
  x86: dsputil: Move specific optimization settings out of global init function
  avplay: get rid of ugly casts in the options table
  avplay: fix prototypes for option callbacks.
  flvdec: always set AVFMTCTX_NOHEADER.
  file: Use a normal private context for storing the file descriptor
  configure: Adjust the xgetbv instrinsic check
  configure: Add --disable-inline-asm command line option
  configure: Don't try to enable the log2 function on msvcrt

Conflicts:
	configure
	ffplay.c
	libavcodec/x86/dsputil_mmx.c
	libavformat/file.c
	libavformat/flvdec.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 7b56dddd 55e778be
......@@ -290,6 +290,7 @@ Optimization options (experts only):
--disable-mmi disable MMI optimizations
--disable-neon disable NEON optimizations
--disable-vis disable VIS optimizations
--disable-inline-asm disable use of inline assembler
--disable-yasm disable use of yasm assembler
--disable-mips32r2 disable MIPS32R2 optimizations
--disable-mipsdspr1 disable MIPS DSP ASE R1 optimizations
......@@ -1429,6 +1430,7 @@ CMDLINE_SELECT="
cross_compile
debug
extra_warnings
inline_asm
logging
optimizations
stripping
......@@ -1549,6 +1551,8 @@ need_memalign="altivec neon sse"
symver_if_any="symver_asm_label symver_gnu_asm"
log2_deps="!msvcrt"
# subsystems
dct_select="rdft"
mdct_select="fft"
......@@ -3241,7 +3245,7 @@ EOF
sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
extern_prefix=${sym%%ff_extern*}
check_cc <<EOF && enable inline_asm
check_cc <<EOF && enable_weak inline_asm
void foo(void) { __asm__ volatile ("" ::); }
EOF
......@@ -3350,7 +3354,7 @@ elif enabled sparc; then
elif enabled x86; then
check_code ld immintrin.h "__xgetbv(0)" "cc" && enable xgetbv
check_code ld immintrin.h "return __xgetbv(0)" "cc" && enable xgetbv
check_code ld intrin.h "int info[4]; __cpuid(info, 0)" "cc" && enable cpuid
check_code ld intrin.h "__rdtsc()" "cc" && enable rdtsc
check_code ld intrin.h "unsigned int x = __readeflags()" "cc" && enable rweflags
......
......@@ -44,23 +44,28 @@
/* standard file protocol */
typedef struct FileContext {
int fd;
} FileContext;
static int file_read(URLContext *h, unsigned char *buf, int size)
{
int fd = (intptr_t) h->priv_data;
int r = read(fd, buf, size);
FileContext *c = h->priv_data;
int r = read(c->fd, buf, size);
return (-1 == r)?AVERROR(errno):r;
}
static int file_write(URLContext *h, const unsigned char *buf, int size)
{
int fd = (intptr_t) h->priv_data;
int r = write(fd, buf, size);
FileContext *c = h->priv_data;
int r = write(c->fd, buf, size);
return (-1 == r)?AVERROR(errno):r;
}
static int file_get_handle(URLContext *h)
{
return (intptr_t) h->priv_data;
FileContext *c = h->priv_data;
return c->fd;
}
static int file_check(URLContext *h, int mask)
......@@ -80,6 +85,7 @@ static int file_check(URLContext *h, int mask)
static int file_open(URLContext *h, const char *filename, int flags)
{
FileContext *c = h->priv_data;
int access;
int fd;
struct stat st;
......@@ -99,7 +105,7 @@ static int file_open(URLContext *h, const char *filename, int flags)
fd = open(filename, access, 0666);
if (fd == -1)
return AVERROR(errno);
h->priv_data = (void *) (intptr_t) fd;
c->fd = fd;
h->is_streamed = !fstat(fd, &st) && S_ISFIFO(st.st_mode);
......@@ -109,19 +115,19 @@ static int file_open(URLContext *h, const char *filename, int flags)
/* XXX: use llseek */
static int64_t file_seek(URLContext *h, int64_t pos, int whence)
{
int fd = (intptr_t) h->priv_data;
FileContext *c = h->priv_data;
if (whence == AVSEEK_SIZE) {
struct stat st;
int ret = fstat(fd, &st);
int ret = fstat(c->fd, &st);
return ret < 0 ? AVERROR(errno) : (S_ISFIFO(st.st_mode) ? 0 : st.st_size);
}
return lseek(fd, pos, whence);
return lseek(c->fd, pos, whence);
}
static int file_close(URLContext *h)
{
int fd = (intptr_t) h->priv_data;
return close(fd);
FileContext *c = h->priv_data;
return close(c->fd);
}
URLProtocol ff_file_protocol = {
......@@ -133,6 +139,7 @@ URLProtocol ff_file_protocol = {
.url_close = file_close,
.url_get_file_handle = file_get_handle,
.url_check = file_check,
.priv_data_size = sizeof(FileContext),
};
#endif /* CONFIG_FILE_PROTOCOL */
......@@ -141,6 +148,7 @@ URLProtocol ff_file_protocol = {
static int pipe_open(URLContext *h, const char *filename, int flags)
{
FileContext *c = h->priv_data;
int fd;
char *final;
av_strstart(filename, "pipe:", &filename);
......@@ -156,7 +164,7 @@ static int pipe_open(URLContext *h, const char *filename, int flags)
#if HAVE_SETMODE
setmode(fd, O_BINARY);
#endif
h->priv_data = (void *) (intptr_t) fd;
c->fd = fd;
h->is_streamed = 1;
return 0;
}
......@@ -168,6 +176,7 @@ URLProtocol ff_pipe_protocol = {
.url_write = file_write,
.url_get_file_handle = file_get_handle,
.url_check = file_check,
.priv_data_size = sizeof(FileContext),
};
#endif /* CONFIG_PIPE_PROTOCOL */
......@@ -503,7 +503,8 @@ static int flv_read_header(AVFormatContext *s)
flags = FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO;
av_log(s, AV_LOG_WARNING, "Broken FLV file, which says no streams present, this might fail\n");
}
s->ctx_flags |= AVFMTCTX_NOHEADER;
s->ctx_flags |= AVFMTCTX_NOHEADER;
if(flags & FLV_HEADER_FLAG_HASVIDEO){
if(!create_stream(s, AVMEDIA_TYPE_VIDEO))
......@@ -729,6 +730,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_WARNING, "Stream discovered after head already parsed\n");
st = create_stream(s,
(int[]){AVMEDIA_TYPE_VIDEO, AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_DATA}[stream_type]);
}
av_dlog(s, "%d %X %d \n", stream_type, flags, st->discard);
if( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || (stream_type == FLV_STREAM_TYPE_AUDIO)))
......
......@@ -33,6 +33,28 @@ struct PayloadContext {
int hdr_size; ///< size of the current frame header
};
static const uint8_t default_quantizers[128] = {
/* luma table */
16, 11, 12, 14, 12, 10, 16, 14,
13, 14, 18, 17, 16, 19, 24, 40,
26, 24, 22, 22, 24, 49, 35, 37,
29, 40, 58, 51, 61, 60, 57, 51,
56, 55, 64, 72, 92, 78, 64, 68,
87, 69, 55, 56, 80, 109, 81, 87,
95, 98, 103, 104, 103, 62, 77, 113,
121, 112, 100, 120, 92, 101, 103, 99,
/* chroma table */
17, 18, 18, 24, 21, 24, 47, 26,
26, 47, 99, 66, 56, 66, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
static PayloadContext *jpeg_new_context(void)
{
return av_mallocz(sizeof(PayloadContext));
......@@ -170,6 +192,27 @@ static int jpeg_create_header(uint8_t *buf, int size, uint32_t type, uint32_t w,
return put_bits_count(&pbc) / 8;
}
static void create_default_qtables(uint8_t *qtables, uint8_t q)
{
int factor = q;
int i;
factor = av_clip(q, 1, 99);
if (q < 50)
q = 5000 / factor;
else
q = 200 - factor * 2;
for (i = 0; i < 128; i++) {
int val = (default_quantizers[i] * q + 50) / 100;
/* Limit the quantizers to 1 <= q <= 255. */
val = av_clip(val, 1, 255);
qtables[i] = val;
}
}
static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, int flags)
......@@ -238,6 +281,7 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
if (off == 0) {
/* Start of JPEG data packet. */
uint8_t new_qtables[128];
uint8_t hdr[1024];
/* Skip the current frame in case of the end packet
......@@ -249,9 +293,9 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg,
jpeg->timestamp = *timestamp;
if (!qtables) {
av_log(ctx, AV_LOG_ERROR,
"Unimplemented default quantization tables.\n");
return AVERROR_PATCHWELCOME;
create_default_qtables(new_qtables, q);
qtables = new_qtables;
qtable_len = sizeof(new_qtables);
}
/* Generate a frame and scan headers that can be prepended to the
......
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