Commit 2a976deb authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  dv: Initialize encoder tables during encoder init.
  dv: Replace some magic numbers by the appropriate #define.
  FATE: pass the decoded output format and audio source file to enc_dec_pcm
  FATE: specify the input format when decoding in enc_dec_pcm()
  x86inc: support AVX abstraction for 2-operand instructions
  configure: detect PGI compiler and set suitable flags
  avconv: check for an incompatible changing channel layout
  avio: make AVIOContext.av_class pointer to const
  nutdec: add malloc check and fix const to non-const conversion warnings

Conflicts:
	ffmpeg.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 2ff935f4 2b983779
......@@ -2344,6 +2344,24 @@ elif $cc -v 2>&1 | grep -q Open64; then
speed_cflags='-O2'
size_cflags='-Os'
filter_cflags='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
elif $cc -V 2>&1 | grep -q Portland; then
cc_type=pgi
cc_version='AV_STRINGIFY(__PGIC__.__PGIC_MINOR__.__PGIC_PATCHLEVEL__)'
cc_ident="PGI $($cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
opt_common='-alias=ansi -Mlre -Mpre'
speed_cflags="-O3 -Mautoinline -Munroll=c:4 $opt_common"
size_cflags="-O2 -Munroll=c:1 $opt_common"
noopt_cflags="-O1"
filter_cflags=pgi_flags
pgi_flags(){
for flag; do
case $flag in
-fomit-frame-pointer) echo -Mnoframe ;;
-g) echo -gopt ;;
*) echo $flag ;;
esac
done
}
fi
test -n "$cc_type" && enable $cc_type ||
......
......@@ -1381,6 +1381,58 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
}
}
static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)
{
char layout_name[256];
AVCodecContext *enc = ost->st->codec;
AVCodecContext *dec = ist->st->codec;
if (dec->channel_layout &&
av_get_channel_layout_nb_channels(dec->channel_layout) != dec->channels) {
av_get_channel_layout_string(layout_name, sizeof(layout_name),
dec->channels, dec->channel_layout);
av_log(NULL, AV_LOG_ERROR, "New channel layout (%s) is invalid\n",
layout_name);
dec->channel_layout = 0;
}
if (!dec->channel_layout) {
if (enc->channel_layout && dec->channels == enc->channels) {
dec->channel_layout = enc->channel_layout;
} else {
dec->channel_layout = av_get_default_channel_layout(dec->channels);
if (!dec->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel "
"layout for Input Stream #%d.%d\n", ist->file_index,
ist->st->index);
exit_program(1);
}
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
dec->channels, dec->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
"#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
}
if (!enc->channel_layout) {
if (dec->channels == enc->channels) {
enc->channel_layout = dec->channel_layout;
return;
} else {
enc->channel_layout = av_get_default_channel_layout(enc->channels);
}
if (!enc->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel layout "
"for Output Stream #%d.%d\n", ost->file_index,
ost->st->index);
exit_program(1);
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
enc->channels, enc->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Output Stream "
"#%d.%d : %s\n", ost->file_index, ost->st->index, layout_name);
}
}
static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size)
{
int fill_char = 0x00;
......@@ -1515,6 +1567,8 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost,
for(i=0; i<planes; i++)
buf[i]= decoded_frame->data[i];
get_default_channel_layouts(ost, ist);
if (alloc_audio_output_buf(dec, enc, decoded_frame->nb_samples) < 0) {
av_log(NULL, AV_LOG_FATAL, "Error allocating audio buffer\n");
exit_program(1);
......@@ -2742,51 +2796,6 @@ static void print_sdp(void)
av_freep(&avc);
}
static void get_default_channel_layouts(OutputStream *ost, InputStream *ist)
{
char layout_name[256];
AVCodecContext *enc = ost->st->codec;
AVCodecContext *dec = ist->st->codec;
if (!dec->channel_layout) {
if (enc->channel_layout && dec->channels == enc->channels) {
dec->channel_layout = enc->channel_layout;
} else {
dec->channel_layout = av_get_default_channel_layout(dec->channels);
if (!dec->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel "
"layout for Input Stream #%d.%d\n", ist->file_index,
ist->st->index);
exit_program(1);
}
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
dec->channels, dec->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
"#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
}
if (!enc->channel_layout) {
if (dec->channels == enc->channels) {
enc->channel_layout = dec->channel_layout;
return;
} else {
enc->channel_layout = av_get_default_channel_layout(enc->channels);
}
if (!enc->channel_layout) {
av_log(NULL, AV_LOG_FATAL, "Unable to find default channel layout "
"for Output Stream #%d.%d\n", ost->file_index,
ost->st->index);
exit_program(1);
}
av_get_channel_layout_string(layout_name, sizeof(layout_name),
enc->channels, enc->channel_layout);
av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Output Stream "
"#%d.%d : %s\n", ost->file_index, ost->st->index, layout_name);
}
}
static int init_input_stream(int ist_index, char *error, int error_len)
{
int i;
......
......@@ -294,8 +294,6 @@ av_cold int ff_dvvideo_init(AVCodecContext *avctx)
ff_dv_rl_vlc[i].run = run;
}
ff_free_vlc(&dv_vlc);
dv_vlc_map_tableinit();
}
/* Generic DSP setup */
......@@ -338,6 +336,8 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
dv_vlc_map_tableinit();
return ff_dvvideo_init(avctx);
}
......
......@@ -36,7 +36,7 @@
* between (run, level) and vlc is not 1-1. So you have to watch out for that
* when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82.
*/
static const uint16_t dv_vlc_bits[409] = {
static const uint16_t dv_vlc_bits[NB_DV_VLC] = {
0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a,
0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2,
......@@ -91,7 +91,7 @@ static const uint16_t dv_vlc_bits[409] = {
0x0006,
};
static const uint8_t dv_vlc_len[409] = {
static const uint8_t dv_vlc_len[NB_DV_VLC] = {
2, 3, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7,
7, 7, 7, 7, 7, 8, 8, 8,
......@@ -146,7 +146,7 @@ static const uint8_t dv_vlc_len[409] = {
4,
};
static const uint8_t dv_vlc_run[409] = {
static const uint8_t dv_vlc_run[NB_DV_VLC] = {
0, 0, 1, 0, 0, 2, 1, 0,
0, 3, 4, 0, 0, 5, 6, 2,
1, 1, 0, 0, 0, 7, 8, 9,
......@@ -201,7 +201,7 @@ static const uint8_t dv_vlc_run[409] = {
127,
};
static const uint8_t dv_vlc_level[409] = {
static const uint8_t dv_vlc_level[NB_DV_VLC] = {
1, 2, 1, 3, 4, 1, 2, 5,
6, 1, 1, 7, 8, 1, 1, 2,
3, 4, 9, 10, 11, 1, 1, 1,
......
......@@ -78,7 +78,7 @@ typedef struct {
* warning -- this field can be NULL, be sure to not pass this AVIOContext
* to any av_opt_* functions in that case.
*/
AVClass *av_class;
const AVClass *av_class;
unsigned char *buffer; /**< Start of the buffer. */
int buffer_size; /**< Maximum buffer size */
unsigned char *buf_ptr; /**< Current position in the buffer */
......
......@@ -305,14 +305,18 @@ static int decode_main_header(NUTContext *nut)
GET_V(nut->header_count, tmp < 128U)
nut->header_count++;
for (i = 1; i < nut->header_count; i++) {
uint8_t *hdr;
GET_V(nut->header_len[i], tmp > 0 && tmp < 256);
rem -= nut->header_len[i];
if (rem < 0) {
av_log(s, AV_LOG_ERROR, "invalid elision header\n");
return AVERROR_INVALIDDATA;
}
nut->header[i] = av_malloc(nut->header_len[i]);
avio_read(bc, nut->header[i], nut->header_len[i]);
hdr = av_malloc(nut->header_len[i]);
if (!hdr)
return AVERROR(ENOMEM);
avio_read(bc, hdr, nut->header_len[i]);
nut->header[i] = hdr;
}
assert(nut->header_len[0] == 0);
}
......
......@@ -856,7 +856,7 @@ INIT_XMM
;%1 == instruction
;%2 == 1 if float, 0 if int
;%3 == 1 if 4-operand (xmm, xmm, xmm, imm), 0 if 3-operand (xmm, xmm, xmm)
;%3 == 1 if 4-operand (xmm, xmm, xmm, imm), 0 if 2- or 3-operand (xmm, xmm, xmm)
;%4 == number of operands given
;%5+: operands
%macro RUN_AVX_INSTR 6-7+
......@@ -866,7 +866,11 @@ INIT_XMM
%define %%size mmsize
%endif
%if %%size==32
v%1 %5, %6, %7
%if %0 >= 7
v%1 %5, %6, %7
%else
v%1 %5, %6
%endif
%else
%if %%size==8
%define %%regmov movq
......@@ -952,6 +956,8 @@ AVX_INSTR cmppd, 1, 0, 0
AVX_INSTR cmpps, 1, 0, 0
AVX_INSTR cmpsd, 1, 0, 0
AVX_INSTR cmpss, 1, 0, 0
AVX_INSTR cvtdq2ps, 1, 0, 0
AVX_INSTR cvtps2dq, 1, 0, 0
AVX_INSTR divpd, 1, 0, 0
AVX_INSTR divps, 1, 0, 0
AVX_INSTR divsd, 1, 0, 0
......
......@@ -28,6 +28,11 @@ errfile="${outdir}/${test}.err"
cmpfile="${outdir}/${test}.diff"
repfile="${outdir}/${test}.rep"
target_path(){
test ${1} = ${1#/} && p=${target_path}/
echo ${p}${1}
}
# $1=value1, $2=value2, $3=threshold
# prints 0 if absolute difference between value1 and value2 is <= threshold
compare(){
......@@ -86,12 +91,15 @@ pcm(){
enc_dec_pcm(){
out_fmt=$1
pcm_fmt=$2
shift 2
dec_fmt=$2
pcm_fmt=$3
src_file=$(target_path $4)
shift 4
encfile="${outdir}/${test}.${out_fmt}"
cleanfiles=$encfile
avconv -i $ref "$@" -f $out_fmt -y ${target_path}/${encfile} || return
avconv -i ${target_path}/${encfile} -c:a pcm_${pcm_fmt} -f wav -
encfile=$(target_path ${encfile})
avconv -i $src_file "$@" -f $out_fmt -y ${encfile} || return
avconv -i ${encfile} -c:a pcm_${pcm_fmt} -f ${dec_fmt} -
}
regtest(){
......
......@@ -73,7 +73,7 @@ FATE_AAC += $(FATE_AAC_CT:%=fate-aac-ct-%)
FATE_AAC_ENCODE += fate-aac-aref-encode
fate-aac-aref-encode: $(AREF)
fate-aac-aref-encode: CMD = enc_dec_pcm adts s16le -strict -2 -c:a aac -b:a 512k
fate-aac-aref-encode: CMD = enc_dec_pcm adts wav s16le $(REF) -strict -2 -c:a aac -b:a 512k
fate-aac-aref-encode: CMP = stddev
fate-aac-aref-encode: REF = ./tests/data/acodec.ref.wav
fate-aac-aref-encode: CMP_SHIFT = -4096
......@@ -81,7 +81,7 @@ fate-aac-aref-encode: CMP_TARGET = 1862
fate-aac-aref-encode: SIZE_TOLERANCE = 2464
FATE_AAC_ENCODE += fate-aac-ln-encode
fate-aac-ln-encode: CMD = enc_dec_pcm adts s16le -strict -2 -c:a aac -b:a 512k
fate-aac-ln-encode: CMD = enc_dec_pcm adts wav s16le $(REF) -strict -2 -c:a aac -b:a 512k
fate-aac-ln-encode: CMP = stddev
fate-aac-ln-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
fate-aac-ln-encode: CMP_SHIFT = -4096
......
......@@ -29,7 +29,7 @@ fate-eac3-4: CMP = oneoff
fate-eac3-4: REF = $(SAMPLES)/eac3/serenity_english_5.1_1536_small.pcm
FATE_AC3 += fate-ac3-encode
fate-ac3-encode: CMD = enc_dec_pcm ac3 s16le -c:a ac3 -b:a 128k
fate-ac3-encode: CMD = enc_dec_pcm ac3 wav s16le $(REF) -c:a ac3 -b:a 128k
fate-ac3-encode: CMP = stddev
fate-ac3-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
fate-ac3-encode: CMP_SHIFT = -1024
......@@ -37,7 +37,7 @@ fate-ac3-encode: CMP_TARGET = 399.62
fate-ac3-encode: SIZE_TOLERANCE = 488
FATE_AC3 += fate-eac3-encode
fate-eac3-encode: CMD = enc_dec_pcm eac3 s16le -c:a eac3 -b:a 128k
fate-eac3-encode: CMD = enc_dec_pcm eac3 wav s16le $(REF) -c:a eac3 -b:a 128k
fate-eac3-encode: CMP = stddev
fate-eac3-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
fate-eac3-encode: CMP_SHIFT = -1024
......
......@@ -30,7 +30,7 @@ fate-nellymoser: REF = $(SAMPLES)/nellymoser/nellymoser.pcm
FATE_AUDIO += fate-nellymoser-aref-encode
fate-nellymoser-aref-encode: $(AREF)
fate-nellymoser-aref-encode: CMD = enc_dec_pcm flv s16le -c:a nellymoser
fate-nellymoser-aref-encode: CMD = enc_dec_pcm flv wav s16le $(REF) -c:a nellymoser
fate-nellymoser-aref-encode: CMP = stddev
fate-nellymoser-aref-encode: REF = ./tests/data/acodec-16000-1.ref.wav
fate-nellymoser-aref-encode: CMP_SHIFT = -1172
......
......@@ -38,7 +38,7 @@ FATE_TESTS += $(FATE_WMAVOICE)
fate-wmavoice: $(FATE_WMAVOICE)
FATE_WMA_ENCODE += fate-wmav1-encode
fate-wmav1-encode: CMD = enc_dec_pcm asf s16le -c:a wmav1 -b:a 128k
fate-wmav1-encode: CMD = enc_dec_pcm asf wav s16le $(REF) -c:a wmav1 -b:a 128k
fate-wmav1-encode: CMP = stddev
fate-wmav1-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
fate-wmav1-encode: CMP_SHIFT = -8192
......@@ -46,7 +46,7 @@ fate-wmav1-encode: CMP_TARGET = 291.06
fate-wmav1-encode: SIZE_TOLERANCE = 4632
FATE_WMA_ENCODE += fate-wmav2-encode
fate-wmav2-encode: CMD = enc_dec_pcm asf s16le -c:a wmav2 -b:a 128k
fate-wmav2-encode: CMD = enc_dec_pcm asf wav s16le $(REF) -c:a wmav2 -b:a 128k
fate-wmav2-encode: CMP = stddev
fate-wmav2-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
fate-wmav2-encode: CMP_SHIFT = -8192
......
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