diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-09 12:13:58 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-01-09 12:14:56 +0100 |
commit | 75afbe2ab4a14cdfdc4001869ae67ded99cf5ce7 (patch) | |
tree | a71971845a2b85bddf8bbcfe4227dd370341f000 | |
parent | 34c1c08c665389daa190cb331e4d899da8dde57a (diff) | |
parent | 1fb8f6a44f06e48386450fe0363aefc02583d24a (diff) | |
download | ffmpeg-75afbe2ab4a14cdfdc4001869ae67ded99cf5ce7.tar.gz |
Merge commit '1fb8f6a44f06e48386450fe0363aefc02583d24a'
* commit '1fb8f6a44f06e48386450fe0363aefc02583d24a':
x86: lavr: add SSE2 quantize() for dithering
doc/APIchanges: fill in missing dates and hashes.
rtpdec_vp8: Request a keyframe if RTP packets are lost
Conflicts:
doc/APIchanges
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | doc/APIchanges | 22 | ||||
-rw-r--r-- | libavformat/rtpdec_vp8.c | 28 | ||||
-rw-r--r-- | libavresample/dither.c | 3 | ||||
-rw-r--r-- | libavresample/dither.h | 5 | ||||
-rw-r--r-- | libavresample/x86/Makefile | 2 | ||||
-rw-r--r-- | libavresample/x86/dither.asm | 53 | ||||
-rw-r--r-- | libavresample/x86/dither_init.c | 39 |
7 files changed, 140 insertions, 12 deletions
diff --git a/doc/APIchanges b/doc/APIchanges index fc5c3f2cb7..4ec6ebb0d8 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -132,34 +132,34 @@ API changes, most recent first: 2012-03-26 - a67d9cf - lavfi 2.66.100 Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. -2013-xx-xx - xxxxxxx - lavr 1.1.0 +2013-01-07 - 074a00d - lavr 1.1.0 Add avresample_set_channel_mapping() for input channel reordering, duplication, and silencing. -2012-xx-xx - xxxxxxx - lavu 52.2.1 - avstring.h +2012-12-29 - d8fd06c - lavu 52.2.1 - avstring.h Add av_basename() and av_dirname(). -2012-11-10 - 5980f5dd - lavu 52.2.0 - audioconvert.h +2012-11-11 - 5980f5d - lavu 52.2.0 - audioconvert.h Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated. -2012-10-26 - dfde8a34 - lavu 52.1.0 - intmath.h - Add av_ctz() for trailing zero bit count. +2012-11-05 - dfde8a3 - lavu 52.1.0 - intmath.h + Add av_ctz() for trailing zero bit count -2012-10-18 - a893655b - lavu 51.45.0 - error.h - Add AVERROR_EXPERIMENTAL. +2012-10-21 - a893655 - lavu 51.45.0 - error.h + Add AVERROR_EXPERIMENTAL -2012-10-12 - d2fcb356 - lavu 51.44.0 - pixdesc.h +2012-10-12 - d2fcb35 - lavu 51.44.0 - pixdesc.h Add functions for accessing pixel format descriptors. Accessing the av_pix_fmt_descriptors array directly is now deprecated. -2012-10-11 - 9a92aea2 - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h +2012-10-11 - 9a92aea - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h Add functions for allocating the opaque contexts for the algorithms, -2012-10-10 - b522000e - lavf 54.18.0 - avio.h +2012-10-10 - b522000 - lavf 54.18.0 - avio.h Add avio_closep to complement avio_close. -2012-10-06 - 78071a14 - lavu 51.42.0 - pixfmt.h +2012-10-08 - 78071a1 - lavu 51.42.0 - pixfmt.h Rename PixelFormat to AVPixelFormat and all PIX_FMT_* to AV_PIX_FMT_*. To provide backwards compatibility, PixelFormat is now #defined as AVPixelFormat. diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index 884abcc8da..9d6a6972fc 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -35,11 +35,21 @@ struct PayloadContext { AVIOContext *data; uint32_t timestamp; int is_keyframe; + /* If sequence_ok is set, we keep returning data (even if we might have + * lost some data, but we haven't lost any too critical data that would + * cause the decoder to desynchronize and output random garbage). + */ int sequence_ok; int first_part_size; uint16_t prev_seq; int prev_pictureid; int broken_frame; + /* If sequence_dirty is set, we have lost some data (critical or + * non-critical) and decoding will have some sort of artefacts, and + * we thus should request a new keyframe. + */ + int sequence_dirty; + int got_keyframe; }; static void vp8_free_buffer(PayloadContext *vp8) @@ -141,11 +151,15 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, vp8_free_buffer(vp8); // Keyframe, decoding ok again vp8->sequence_ok = 1; + vp8->sequence_dirty = 0; + vp8->got_keyframe = 1; } else { int can_continue = vp8->data && !vp8->is_keyframe && avio_tell(vp8->data) >= vp8->first_part_size; if (!vp8->sequence_ok) return AVERROR(EAGAIN); + if (!vp8->got_keyframe) + return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n"); if (pictureid >= 0) { if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) { return vp8_broken_sequence(ctx, vp8, @@ -179,6 +193,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, } } if (vp8->data) { + vp8->sequence_dirty = 1; if (avio_tell(vp8->data) >= vp8->first_part_size) { int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) @@ -220,6 +235,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, "Missed part of a keyframe, sequence broken\n"); } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) { vp8->broken_frame = 1; + vp8->sequence_dirty = 1; } else { return vp8_broken_sequence(ctx, vp8, "Missed part of the first partition, sequence broken\n"); @@ -253,7 +269,11 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, static PayloadContext *vp8_new_context(void) { - return av_mallocz(sizeof(PayloadContext)); + PayloadContext *vp8 = av_mallocz(sizeof(PayloadContext)); + if (!vp8) + return NULL; + vp8->sequence_ok = 1; + return vp8; } static void vp8_free_context(PayloadContext *vp8) @@ -262,6 +282,11 @@ static void vp8_free_context(PayloadContext *vp8) av_free(vp8); } +static int vp8_need_keyframe(PayloadContext *vp8) +{ + return vp8->sequence_dirty || !vp8->sequence_ok; +} + RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { .enc_name = "VP8", .codec_type = AVMEDIA_TYPE_VIDEO, @@ -269,4 +294,5 @@ RTPDynamicProtocolHandler ff_vp8_dynamic_handler = { .alloc = vp8_new_context, .free = vp8_free_context, .parse_packet = vp8_handle_packet, + .need_keyframe = vp8_need_keyframe, }; diff --git a/libavresample/dither.c b/libavresample/dither.c index dfff03e756..f24bf5c765 100644 --- a/libavresample/dither.c +++ b/libavresample/dither.c @@ -336,6 +336,9 @@ static void dither_init(DitherDSPContext *ddsp, ddsp->dither_int_to_float = dither_int_to_float_rectangular_c; else ddsp->dither_int_to_float = dither_int_to_float_triangular_c; + + if (ARCH_X86) + ff_dither_init_x86(ddsp, method); } DitherContext *ff_dither_alloc(AVAudioResampleContext *avr, diff --git a/libavresample/dither.h b/libavresample/dither.h index d6a7d3ea8d..8db37146fa 100644 --- a/libavresample/dither.h +++ b/libavresample/dither.h @@ -85,4 +85,9 @@ void ff_dither_free(DitherContext **c); */ int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src); +/* arch-specific initialization functions */ + +void ff_dither_init_x86(DitherDSPContext *ddsp, + enum AVResampleDitherMethod method); + #endif /* AVRESAMPLE_DITHER_H */ diff --git a/libavresample/x86/Makefile b/libavresample/x86/Makefile index 65bed899ba..2e8786fb90 100644 --- a/libavresample/x86/Makefile +++ b/libavresample/x86/Makefile @@ -1,5 +1,7 @@ OBJS += x86/audio_convert_init.o \ x86/audio_mix_init.o \ + x86/dither_init.o \ YASM-OBJS += x86/audio_convert.o \ x86/audio_mix.o \ + x86/dither.o \ diff --git a/libavresample/x86/dither.asm b/libavresample/x86/dither.asm new file mode 100644 index 0000000000..bfdc4e6907 --- /dev/null +++ b/libavresample/x86/dither.asm @@ -0,0 +1,53 @@ +;****************************************************************************** +;* x86 optimized dithering format conversion +;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg 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. +;* +;* FFmpeg 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 FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +SECTION_RODATA 32 + +pf_s16_scale: times 4 dd 32753.0 + +SECTION_TEXT + +;------------------------------------------------------------------------------ +; void ff_quantize(int16_t *dst, float *src, float *dither, int len); +;------------------------------------------------------------------------------ + +INIT_XMM sse2 +cglobal quantize, 4,4,3, dst, src, dither, len + lea lenq, [2*lend] + add dstq, lenq + lea srcq, [srcq+2*lenq] + lea ditherq, [ditherq+2*lenq] + neg lenq + mova m2, [pf_s16_scale] +.loop: + mulps m0, m2, [srcq+2*lenq] + mulps m1, m2, [srcq+2*lenq+mmsize] + addps m0, [ditherq+2*lenq] + addps m1, [ditherq+2*lenq+mmsize] + cvtps2dq m0, m0 + cvtps2dq m1, m1 + packssdw m0, m1 + mova [dstq+lenq], m0 + add lenq, mmsize + jl .loop + REP_RET diff --git a/libavresample/x86/dither_init.c b/libavresample/x86/dither_init.c new file mode 100644 index 0000000000..d5d92902fd --- /dev/null +++ b/libavresample/x86/dither_init.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> + * + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" +#include "libavresample/dither.h" + +extern void ff_quantize_sse2(int16_t *dst, const float *src, float *dither, + int len); + +av_cold void ff_dither_init_x86(DitherDSPContext *ddsp, + enum AVResampleDitherMethod method) +{ + int mm_flags = av_get_cpu_flags(); + + if (EXTERNAL_SSE2(mm_flags)) { + ddsp->quantize = ff_quantize_sse2; + ddsp->ptr_align = 16; + ddsp->samples_align = 8; + } +} |