* qatar/master: lavf: Detect discontinuities in timestamps for framerate/analyzeduration calculation lavf: Initialize the stream info timestamps in avformat_new_stream id3v2: Match PIC mimetype/format case-insensitively configure: Rename check_asm() to more fitting check_inline_asm() fate: Only test enabled filters avresample: De-doxygenize some comments where Doxygen is not appropriate rtmp: split chunk_size var into in_chunk_size and out_chunk_size rtmp: Factorize the code by adding find_tracked_method Conflicts: configure Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n1.0
| @@ -711,8 +711,8 @@ check_as(){ | |||
| check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C -o $TMPO $TMPC | |||
| } | |||
| check_asm(){ | |||
| log check_asm "$@" | |||
| check_inline_asm(){ | |||
| log check_inline_asm "$@" | |||
| name="$1" | |||
| code="$2" | |||
| shift 2 | |||
| @@ -3123,40 +3123,39 @@ EOF | |||
| warn "Compiler does not indicate floating-point ABI, guessing $fpabi." | |||
| fi | |||
| enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"' | |||
| enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"' | |||
| enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"' | |||
| enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"' | |||
| enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"' | |||
| enabled vfpv3 && check_asm vfpv3 '"vmov.f32 s0, #1.0"' | |||
| enabled armv5te && check_inline_asm armv5te '"qadd r0, r0, r0"' | |||
| enabled armv6 && check_inline_asm armv6 '"sadd16 r0, r0, r0"' | |||
| enabled armv6t2 && check_inline_asm armv6t2 '"movt r0, #0"' | |||
| enabled armvfp && check_inline_asm armvfp '"fadds s0, s0, s0"' | |||
| enabled neon && check_inline_asm neon '"vadd.i16 q0, q0, q0"' | |||
| enabled vfpv3 && check_inline_asm vfpv3 '"vmov.f32 s0, #1.0"' | |||
| check_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)' | |||
| check_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)' | |||
| check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)' | |||
| check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)' | |||
| enabled_all armv6t2 shared !pic && enable_pic | |||
| elif enabled mips; then | |||
| check_asm loongson '"dmult.g $1, $2, $3"' | |||
| enabled mmi && check_asm mmi '"lq $2, 0($2)"' | |||
| check_inline_asm loongson '"dmult.g $1, $2, $3"' | |||
| enabled mmi && check_inline_asm mmi '"lq $2, 0($2)"' | |||
| enabled mips32r2 && add_cflags "-mips32r2" && | |||
| check_asm mips32r2 '"rotr $t0, $t1, 1"' | |||
| check_inline_asm mips32r2 '"rotr $t0, $t1, 1"' | |||
| enabled mipsdspr1 && add_cflags "-mdsp" && add_asflags "-mdsp" && | |||
| check_asm mipsdspr1 '"addu.qb $t0, $t1, $t2"' | |||
| check_inline_asm mipsdspr1 '"addu.qb $t0, $t1, $t2"' | |||
| enabled mipsdspr2 && add_cflags "-mdspr2" && add_asflags "-mdspr2" && | |||
| check_asm mipsdspr2 '"absq_s.qb $t0, $t1"' | |||
| check_inline_asm mipsdspr2 '"absq_s.qb $t0, $t1"' | |||
| enabled mipsfpu && add_cflags "-mhard-float" && | |||
| check_asm mipsfpu '"madd.d $f0, $f2, $f4, $f6"' | |||
| check_inline_asm mipsfpu '"madd.d $f0, $f2, $f4, $f6"' | |||
| elif enabled ppc; then | |||
| enable local_aligned_8 local_aligned_16 | |||
| check_asm dcbzl '"dcbzl 0, %0" :: "r"(0)' | |||
| check_asm ibm_asm '"add 0, 0, 0"' | |||
| check_asm ppc4xx '"maclhw r10, r11, r12"' | |||
| check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)' | |||
| check_inline_asm dcbzl '"dcbzl 0, %0" :: "r"(0)' | |||
| check_inline_asm ibm_asm '"add 0, 0, 0"' | |||
| check_inline_asm ppc4xx '"maclhw r10, r11, r12"' | |||
| check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)' | |||
| # AltiVec flags: The FSF version of GCC differs from the Apple version | |||
| if enabled altivec; then | |||
| @@ -3184,7 +3183,8 @@ EOF | |||
| elif enabled sparc; then | |||
| enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc && | |||
| enabled vis && | |||
| check_inline_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc && | |||
| add_cflags -mcpu=ultrasparc -mtune=ultrasparc | |||
| elif enabled x86; then | |||
| @@ -3211,15 +3211,15 @@ elif enabled x86; then | |||
| EOF | |||
| # check whether EBX is available on x86 | |||
| check_asm ebx_available '""::"b"(0)' && | |||
| check_asm ebx_available '"":::"%ebx"' | |||
| check_inline_asm ebx_available '""::"b"(0)' && | |||
| check_inline_asm ebx_available '"":::"%ebx"' | |||
| # check whether xmm clobbers are supported | |||
| check_asm xmm_clobbers '"":::"%xmm0"' | |||
| check_inline_asm xmm_clobbers '"":::"%xmm0"' | |||
| # check whether binutils is new enough to compile SSSE3/MMXEXT | |||
| enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"' | |||
| enabled mmxext && check_asm mmxext '"pmaxub %mm0, %mm1"' | |||
| enabled ssse3 && check_inline_asm ssse3 '"pabsw %xmm0, %xmm0"' | |||
| enabled mmxext && check_inline_asm mmxext '"pmaxub %mm0, %mm1"' | |||
| if ! disabled_any asm mmx yasm; then | |||
| if check_cmd $yasmexe --version; then | |||
| @@ -3255,7 +3255,7 @@ fi | |||
| if enabled asm; then | |||
| as=${gas:=$as} | |||
| check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' || | |||
| check_inline_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' || | |||
| $nogas "GNU assembler not found, install gas-preprocessor" | |||
| fi | |||
| @@ -462,7 +462,7 @@ static void read_apic(AVFormatContext *s, AVIOContext *pb, int taglen, char *tag | |||
| /* mimetype */ | |||
| taglen -= avio_get_str(pb, taglen, mimetype, sizeof(mimetype)); | |||
| while (mime->id != AV_CODEC_ID_NONE) { | |||
| if (!strncmp(mime->str, mimetype, sizeof(mimetype))) { | |||
| if (!av_strncasecmp(mime->str, mimetype, sizeof(mimetype))) { | |||
| id = mime->id; | |||
| break; | |||
| } | |||
| @@ -68,7 +68,8 @@ typedef struct RTMPContext { | |||
| const AVClass *class; | |||
| URLContext* stream; ///< TCP stream used in interactions with RTMP server | |||
| RTMPPacket prev_pkt[2][RTMP_CHANNELS]; ///< packet history used when reading and sending packets | |||
| int chunk_size; ///< size of the chunks RTMP packets are divided into | |||
| int in_chunk_size; ///< size of the chunks incoming RTMP packets are divided into | |||
| int out_chunk_size; ///< size of the chunks outgoing RTMP packets are divided into | |||
| int is_input; ///< input/output flag | |||
| char *playpath; ///< stream identifier to play (with possible "mp4:" prefix) | |||
| int live; ///< 0: recorded, -1: live, -2: both | |||
| @@ -154,6 +155,31 @@ static void del_tracked_method(RTMPContext *rt, int index) | |||
| rt->nb_tracked_methods--; | |||
| } | |||
| static int find_tracked_method(URLContext *s, RTMPPacket *pkt, int offset, | |||
| char **tracked_method) | |||
| { | |||
| RTMPContext *rt = s->priv_data; | |||
| GetByteContext gbc; | |||
| double pkt_id; | |||
| int ret; | |||
| int i; | |||
| bytestream2_init(&gbc, pkt->data + offset, pkt->data_size - offset); | |||
| if ((ret = ff_amf_read_number(&gbc, &pkt_id)) < 0) | |||
| return ret; | |||
| for (i = 0; i < rt->nb_tracked_methods; i++) { | |||
| if (rt->tracked_methods[i].id != pkt_id) | |||
| continue; | |||
| *tracked_method = rt->tracked_methods[i].name; | |||
| del_tracked_method(rt, i); | |||
| break; | |||
| } | |||
| return 0; | |||
| } | |||
| static void free_tracked_methods(RTMPContext *rt) | |||
| { | |||
| int i; | |||
| @@ -184,7 +210,7 @@ static int rtmp_send_packet(RTMPContext *rt, RTMPPacket *pkt, int track) | |||
| goto fail; | |||
| } | |||
| ret = ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size, | |||
| ret = ff_rtmp_packet_write(rt->stream, pkt, rt->out_chunk_size, | |||
| rt->prev_pkt[1]); | |||
| fail: | |||
| ff_rtmp_packet_destroy(pkt); | |||
| @@ -940,17 +966,22 @@ static int handle_chunk_size(URLContext *s, RTMPPacket *pkt) | |||
| } | |||
| if (!rt->is_input) { | |||
| if ((ret = ff_rtmp_packet_write(rt->stream, pkt, rt->chunk_size, | |||
| /* Send the same chunk size change packet back to the server, | |||
| * setting the outgoing chunk size to the same as the incoming one. */ | |||
| if ((ret = ff_rtmp_packet_write(rt->stream, pkt, rt->out_chunk_size, | |||
| rt->prev_pkt[1])) < 0) | |||
| return ret; | |||
| rt->out_chunk_size = AV_RB32(pkt->data); | |||
| } | |||
| rt->chunk_size = AV_RB32(pkt->data); | |||
| if (rt->chunk_size <= 0) { | |||
| av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", rt->chunk_size); | |||
| rt->in_chunk_size = AV_RB32(pkt->data); | |||
| if (rt->in_chunk_size <= 0) { | |||
| av_log(s, AV_LOG_ERROR, "Incorrect chunk size %d\n", | |||
| rt->in_chunk_size); | |||
| return AVERROR_INVALIDDATA; | |||
| } | |||
| av_log(s, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size); | |||
| av_log(s, AV_LOG_DEBUG, "New incoming chunk size = %d\n", | |||
| rt->in_chunk_size); | |||
| return 0; | |||
| } | |||
| @@ -1039,24 +1070,11 @@ static int handle_invoke_result(URLContext *s, RTMPPacket *pkt) | |||
| { | |||
| RTMPContext *rt = s->priv_data; | |||
| char *tracked_method = NULL; | |||
| GetByteContext gbc; | |||
| double pkt_id; | |||
| int ret = 0; | |||
| int i; | |||
| bytestream2_init(&gbc, pkt->data + 10, pkt->data_size); | |||
| if ((ret = ff_amf_read_number(&gbc, &pkt_id)) < 0) | |||
| if ((ret = find_tracked_method(s, pkt, 10, &tracked_method)) < 0) | |||
| return ret; | |||
| for (i = 0; i < rt->nb_tracked_methods; i++) { | |||
| if (rt->tracked_methods[i].id != pkt_id) | |||
| continue; | |||
| tracked_method = rt->tracked_methods[i].name; | |||
| del_tracked_method(rt, i); | |||
| break; | |||
| } | |||
| if (!tracked_method) { | |||
| /* Ignore this reply when the current method is not tracked. */ | |||
| return ret; | |||
| @@ -1240,7 +1258,7 @@ static int get_packet(URLContext *s, int for_header) | |||
| for (;;) { | |||
| RTMPPacket rpkt = { 0 }; | |||
| if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt, | |||
| rt->chunk_size, rt->prev_pkt[0])) <= 0) { | |||
| rt->in_chunk_size, rt->prev_pkt[0])) <= 0) { | |||
| if (ret == 0) { | |||
| return AVERROR(EAGAIN); | |||
| } else { | |||
| @@ -1399,7 +1417,8 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) | |||
| if ((ret = rtmp_handshake(s, rt)) < 0) | |||
| goto fail; | |||
| rt->chunk_size = 128; | |||
| rt->out_chunk_size = 128; | |||
| rt->in_chunk_size = 128; // Probably overwritten later | |||
| rt->state = STATE_HANDSHAKED; | |||
| // Keep the application name when it has been defined by the user. | |||
| @@ -1653,7 +1672,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size) | |||
| RTMPPacket rpkt = { 0 }; | |||
| if ((ret = ff_rtmp_packet_read_internal(rt->stream, &rpkt, | |||
| rt->chunk_size, | |||
| rt->in_chunk_size, | |||
| rt->prev_pkt[0], c)) <= 0) | |||
| return ret; | |||
| @@ -2657,6 +2657,19 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) | |||
| st->info->fps_last_dts, st->codec_info_nb_frames, pkt->dts); | |||
| st->info->fps_first_dts = st->info->fps_last_dts = AV_NOPTS_VALUE; | |||
| } | |||
| /* check for a discontinuity in dts - if the difference in dts | |||
| * is more than 1000 times the average packet duration in the sequence, | |||
| * we treat it as a discontinuity */ | |||
| if (st->info->fps_last_dts != AV_NOPTS_VALUE && | |||
| st->info->fps_last_dts_idx > st->info->fps_first_dts_idx && | |||
| (pkt->dts - st->info->fps_last_dts) / 1000 > | |||
| (st->info->fps_last_dts - st->info->fps_first_dts) / (st->info->fps_last_dts_idx - st->info->fps_first_dts_idx)) { | |||
| av_log(ic, AV_LOG_WARNING, "DTS discontinuity in stream %d: " | |||
| "packet %d with DTS %"PRId64", packet %d with DTS " | |||
| "%"PRId64"\n", st->index, st->info->fps_last_dts_idx, | |||
| st->info->fps_last_dts, st->codec_info_nb_frames, pkt->dts); | |||
| st->info->fps_first_dts = st->info->fps_last_dts = AV_NOPTS_VALUE; | |||
| } | |||
| /* update stored dts values */ | |||
| if (st->info->fps_first_dts == AV_NOPTS_VALUE) { | |||
| @@ -3103,6 +3116,12 @@ AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) | |||
| st->sample_aspect_ratio = (AVRational){0,1}; | |||
| #if FF_API_R_FRAME_RATE | |||
| st->info->last_dts = AV_NOPTS_VALUE; | |||
| #endif | |||
| st->info->fps_first_dts = AV_NOPTS_VALUE; | |||
| st->info->fps_last_dts = AV_NOPTS_VALUE; | |||
| s->streams[s->nb_streams++] = st; | |||
| return st; | |||
| } | |||
| @@ -67,9 +67,7 @@ struct ResampleContext { | |||
| #include "resample_template.c" | |||
| /** | |||
| * 0th order modified bessel function of the first kind. | |||
| */ | |||
| /* 0th order modified bessel function of the first kind. */ | |||
| static double bessel(double x) | |||
| { | |||
| double v = 1; | |||
| @@ -86,18 +84,7 @@ static double bessel(double x) | |||
| return v; | |||
| } | |||
| /** | |||
| * Build a polyphase filterbank. | |||
| * | |||
| * @param[out] filter filter coefficients | |||
| * @param factor resampling factor | |||
| * @param tap_count tap count | |||
| * @param phase_count phase count | |||
| * @param scale wanted sum of coefficients for each filter | |||
| * @param filter_type filter type | |||
| * @param kaiser_beta kaiser window beta | |||
| * @return 0 on success, negative AVERROR code on failure | |||
| */ | |||
| /* Build a polyphase filterbank. */ | |||
| static int build_filter(ResampleContext *c) | |||
| { | |||
| int ph, i; | |||
| @@ -18,9 +18,9 @@ $(FATE_AMIX): SRC1 = $(TARGET_PATH)/tests/data/asynth-44100-2-2.wav | |||
| $(FATE_AMIX): CMP = oneoff | |||
| $(FATE_AMIX): CMP_UNIT = f32 | |||
| FATE_FILTER += $(FATE_AMIX) | |||
| FATE_FILTER-$(CONFIG_AMIX_FILTER) += $(FATE_AMIX) | |||
| FATE_FILTER += fate-filter-asyncts | |||
| FATE_FILTER-$(CONFIG_ASYNCTS_FILTER) += fate-filter-asyncts | |||
| fate-filter-asyncts: SRC = $(SAMPLES)/nellymoser/nellymoser-discont.flv | |||
| fate-filter-asyncts: CMD = pcm -i $(SRC) -af aresample=min_comp=0.001:min_hard_comp=0.1 | |||
| fate-filter-asyncts: CMP = oneoff | |||
| @@ -28,7 +28,7 @@ fate-filter-asyncts: REF = $(SAMPLES)/nellymoser/nellymoser-discont.pcm | |||
| fate-filter-delogo: CMD = framecrc -i $(SAMPLES)/real/rv30.rm -vf delogo=show=0:x=290:y=25:w=26:h=16 -an | |||
| FATE_FILTER += fate-filter-delogo | |||
| FATE_FILTER-$(CONFIG_DELOGO_FILTER) += fate-filter-delogo | |||
| FATE_YADIF += fate-filter-yadif-mode0 | |||
| fate-filter-yadif-mode0: CMD = framecrc -flags bitexact -idct simple -i $(SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vf yadif=0 | |||
| @@ -36,7 +36,7 @@ fate-filter-yadif-mode0: CMD = framecrc -flags bitexact -idct simple -i $(SAMPLE | |||
| FATE_YADIF += fate-filter-yadif-mode1 | |||
| fate-filter-yadif-mode1: CMD = framecrc -flags bitexact -idct simple -i $(SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vf yadif=1 | |||
| FATE_FILTER += $(FATE_YADIF) | |||
| FATE_FILTER-$(CONFIG_YADIF_FILTER) += $(FATE_YADIF) | |||
| FATE_SAMPLES_AVCONV += $(FATE_FILTER) | |||
| fate-filter: $(FATE_FILTER) | |||
| FATE_SAMPLES_AVCONV += $(FATE_FILTER-yes) | |||
| fate-filter: $(FATE_FILTER-yes) | |||