Merge commit '65d12900432ac880d764edbbd36818431484a76e'

* commit '65d12900432ac880d764edbbd36818431484a76e':
  configure: add --enable-lto option
  x86: cpu: Break out test for cpuid capabilities into separate function
  x86: ff_get_cpu_flags_x86(): Avoid a pointless variable indirection
  build: Factor out mpegaudio dependencies to CONFIG_MPEGAUDIO
  segment: Add comments about calls that only are relevant for some muxers
  segment: Add an option for omitting the first header and final trailer

Conflicts:
	configure
	libavcodec/Makefile
	libavformat/segment.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-10-05 16:52:13 +02:00
commit 2a77d4f70b
4 changed files with 124 additions and 64 deletions

61
configure vendored
View File

@ -268,6 +268,7 @@ Advanced options (experts only):
disable buffer boundary checking in bitreaders
(faster, but may crash)
--enable-memalign-hack emulate memalign, interferes with memory debuggers
--enable-lto use link-time optimization
Optimization options (experts only):
--disable-asm disable all assembler optimizations
@ -1418,6 +1419,7 @@ CONFIG_EXTRA="
huffman
lgplv3
lpc
mpegaudio
mpegaudiodsp
mpegvideo
mpegvideoenc
@ -1439,6 +1441,7 @@ CMDLINE_SELECT="
debug
extra_warnings
logging
lto
optimizations
stripping
"
@ -1563,6 +1566,7 @@ log2_deps="!msvcrt"
dct_select="rdft"
mdct_select="fft"
rdft_select="fft"
mpegaudio_select="mpegaudiodsp"
mpegaudiodsp_select="dct"
mpegvideoenc_select="mpegvideo"
@ -1632,16 +1636,16 @@ loco_decoder_select="golomb"
mdec_decoder_select="error_resilience mpegvideo"
mjpeg_encoder_select="aandcttables mpegvideoenc"
mlp_decoder_select="mlp_parser"
mp1_decoder_select="mpegaudiodsp"
mp1float_decoder_select="mpegaudiodsp"
mp2_decoder_select="mpegaudiodsp"
mp2float_decoder_select="mpegaudiodsp"
mp3_decoder_select="mpegaudiodsp"
mp3adu_decoder_select="mpegaudiodsp"
mp3adufloat_decoder_select="mpegaudiodsp"
mp3float_decoder_select="mpegaudiodsp"
mp3on4_decoder_select="mpegaudiodsp"
mp3on4float_decoder_select="mpegaudiodsp"
mp1_decoder_select="mpegaudio"
mp1float_decoder_select="mpegaudio"
mp2_decoder_select="mpegaudio"
mp2float_decoder_select="mpegaudio"
mp3_decoder_select="mpegaudio"
mp3adu_decoder_select="mpegaudio"
mp3adufloat_decoder_select="mpegaudio"
mp3float_decoder_select="mpegaudio"
mp3on4_decoder_select="mpegaudio"
mp3on4float_decoder_select="mpegaudio"
mpc7_decoder_select="mpegaudiodsp"
mpc8_decoder_select="mpegaudiodsp"
mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
@ -3847,17 +3851,32 @@ void ff_foo(void) {}
EOF
fi
if [ -n "$optflags" ]; then
add_cflags $optflags
elif enabled small; then
add_cflags $cflags_size
elif enabled optimizations; then
add_cflags $cflags_speed
else
add_cflags $cflags_noopt
if [ -z "$optflags" ]; then
if enabled small; then
optflags=$cflags_size
elif enabled optimizations; then
optflags=$cflags_speed
else
optflags=$cflags_noopt
fi
fi
check_cflags -fno-math-errno
check_cflags -fno-signed-zeros
check_optflags(){
check_cflags "$@"
enabled lto && check_ldflags "$@"
}
if enabled lto; then
test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
check_cflags -flto
check_ldflags -flto $cpuflags
fi
check_optflags $optflags
check_optflags -fno-math-errno
check_optflags -fno-signed-zeros
check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
int x;
EOF
@ -3896,7 +3915,7 @@ elif enabled ccc; then
add_cflags -msg_disable ptrmismatch1
add_cflags -msg_disable unreachcode
elif enabled gcc; then
check_cflags -fno-tree-vectorize
check_optflags -fno-tree-vectorize
check_cflags -Werror=implicit-function-declaration
check_cflags -Werror=missing-prototypes
elif enabled llvm_gcc; then

View File

@ -53,6 +53,8 @@ OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o
OBJS-$(CONFIG_LPC) += lpc.o
OBJS-$(CONFIG_LSP) += lsp.o
OBJS-$(CONFIG_MDCT) += mdct_fixed.o mdct_float.o
OBJS-$(CONFIG_MPEGAUDIO) += mpegaudio.o mpegaudiodata.o \
mpegaudiodecheader.o
OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
mpegaudiodsp_data.o \
mpegaudiodsp_fixed.o \
@ -257,30 +259,18 @@ OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
OBJS-$(CONFIG_MOTIONPIXELS_DECODER) += motionpixels.o
OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o ass.o
OBJS-$(CONFIG_MOVTEXT_ENCODER) += movtextenc.o ass_split.o
OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP1FLOAT_DECODER) += mpegaudiodec_float.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec.o
OBJS-$(CONFIG_MP1FLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec.o
OBJS-$(CONFIG_MP2_ENCODER) += mpegaudioenc.o mpegaudio.o \
mpegaudiodata.o mpegaudiodsp_data.o
OBJS-$(CONFIG_MP2FLOAT_DECODER) += mpegaudiodec_float.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP3ADU_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += mpegaudiodec_float.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP3ON4_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o \
mpeg4audio.o
OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += mpegaudiodec_float.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o \
mpeg4audio.o
OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP3FLOAT_DECODER) += mpegaudiodec_float.o mpegaudiodecheader.o \
mpegaudio.o mpegaudiodata.o
OBJS-$(CONFIG_MP2FLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec.o
OBJS-$(CONFIG_MP3ADU_DECODER) += mpegaudiodec.o
OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MP3FLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MP3ON4_DECODER) += mpegaudiodec.o mpeg4audio.o
OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += mpegaudiodec_float.o mpeg4audio.o
OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o
OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o
OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12.o mpeg12data.o \

View File

@ -72,6 +72,7 @@ typedef struct {
char *time_delta_str; ///< approximation value duration used for the segment times
int64_t time_delta;
int individual_header_trailer; /**< Set by a private option. */
int write_header_trailer; /**< Set by a private option. */
int has_video;
double start_time, end_time;
} SegmentContext;
@ -145,7 +146,7 @@ static int segment_start(AVFormatContext *s, int write_header)
return err;
if (oc->oformat->priv_class && oc->priv_data)
av_opt_set(oc->priv_data, "resend_headers", "1", 0);
av_opt_set(oc->priv_data, "resend_headers", "1", 0); /* mpegts specific */
if (write_header) {
if ((err = avformat_write_header(oc, NULL)) < 0)
@ -201,7 +202,7 @@ static int segment_end(AVFormatContext *s, int write_trailer)
AVFormatContext *oc = seg->avf;
int ret = 0;
av_write_frame(oc, NULL); /* Flush any buffered data */
av_write_frame(oc, NULL); /* Flush any buffered data (fragmented mp4) */
if (write_trailer)
ret = av_write_trailer(oc);
@ -288,6 +289,26 @@ end:
return ret;
}
static int open_null_ctx(AVIOContext **ctx)
{
int buf_size = 32768;
uint8_t *buf = av_malloc(buf_size);
if (!buf)
return AVERROR(ENOMEM);
*ctx = avio_alloc_context(buf, buf_size, AVIO_FLAG_WRITE, NULL, NULL, NULL, NULL);
if (!*ctx) {
av_free(buf);
return AVERROR(ENOMEM);
}
return 0;
}
static void close_null_ctx(AVIOContext *pb)
{
av_free(pb->buffer);
av_free(pb);
}
static int seg_write_header(AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
@ -295,6 +316,8 @@ static int seg_write_header(AVFormatContext *s)
int ret, i;
seg->segment_count = 0;
if (!seg->write_header_trailer)
seg->individual_header_trailer = 0;
if (seg->time_str && seg->times_str) {
av_log(s, AV_LOG_ERROR,
@ -379,15 +402,27 @@ static int seg_write_header(AVFormatContext *s)
}
seg->segment_count++;
if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
goto fail;
if (seg->write_header_trailer) {
if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
goto fail;
} else {
if ((ret = open_null_ctx(&oc->pb)) < 0)
goto fail;
}
if ((ret = avformat_write_header(oc, NULL)) < 0) {
avio_close(oc->pb);
goto fail;
}
if (!seg->write_header_trailer) {
close_null_ctx(oc->pb);
if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
goto fail;
}
fail:
if (ret) {
if (seg->list)
@ -454,7 +489,15 @@ static int seg_write_trailer(struct AVFormatContext *s)
{
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
int ret = segment_end(s, 1);
int ret;
if (!seg->write_header_trailer) {
ret = segment_end(s, 0);
open_null_ctx(&oc->pb);
av_write_trailer(oc);
close_null_ctx(oc->pb);
} else {
ret = segment_end(s, 1);
}
if (seg->list)
segment_list_close(s);
@ -486,6 +529,7 @@ static const AVOption options[] = {
{ "segment_times", "set segment split time points", OFFSET(times_str),AV_OPT_TYPE_STRING,{.str = NULL}, 0, 0, E },
{ "segment_wrap", "set number after which the index wraps", OFFSET(segment_idx_wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },
{ "individual_header_trailer", "write header/trailer to each segment", OFFSET(individual_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
{ "write_header_trailer", "write a header to the first segment and a trailer to the last one", OFFSET(write_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
{ NULL },
};

View File

@ -86,6 +86,26 @@
#endif /* HAVE_INLINE_ASM */
#if ARCH_X86_64
#define cpuid_test() 1
#elif HAVE_INLINE_ASM || HAVE_RWEFLAGS
static int cpuid_test(void)
{
x86_reg a, c;
/* Check if CPUID is supported by attempting to toggle the ID bit in
* the EFLAGS register. */
get_eflags(a);
set_eflags(a ^ 0x200000);
get_eflags(c);
return a != c;
}
#endif
/* Function to test if multimedia instructions are supported... */
int ff_get_cpu_flags_x86(void)
{
@ -95,23 +115,10 @@ int ff_get_cpu_flags_x86(void)
int family = 0, model = 0;
union { int i[3]; char c[12]; } vendor;
#if ARCH_X86_32
x86_reg a, c;
/* Check if CPUID is supported by attempting to toggle the ID bit in
* the EFLAGS register. */
get_eflags(a);
set_eflags(a ^ 0x200000);
get_eflags(c);
if (a == c)
if (!cpuid_test())
return 0; /* CPUID not supported */
#endif
cpuid(0, max_std_level, ebx, ecx, edx);
vendor.i[0] = ebx;
vendor.i[1] = edx;
vendor.i[2] = ecx;
cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]);
if (max_std_level >= 1) {
cpuid(1, eax, ebx, ecx, std_caps);